From 1c2c2ccecb9324096a394b32cdbef4e197803c4d Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 7 Jul 2014 21:11:35 +0200 Subject: [PATCH 001/143] 0.0.11 version --- MQWeb/include/MQ/Web/Version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MQWeb/include/MQ/Web/Version.h b/MQWeb/include/MQ/Web/Version.h index b2debc7..7a650c0 100644 --- a/MQWeb/include/MQ/Web/Version.h +++ b/MQWeb/include/MQ/Web/Version.h @@ -23,10 +23,10 @@ #define MQWEB_VERSION_MAJOR 0 #define MQWEB_VERSION_MINOR 0 -#define MQWEB_RELEASE_NUMBER 10 +#define MQWEB_RELEASE_NUMBER 11 -#define MQWEB_VERSION "0.0.10" -#define MQWEB_COMPLETE_VERSION "MQWeb v0.0.10" +#define MQWEB_VERSION "0.0.11" +#define MQWEB_COMPLETE_VERSION "MQWeb v0.0.11" #endif // _MQWeb_Version_H From 70ab56b942f8b7bfe57e3e921d81bf939d3ee08f Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 8 Jul 2014 17:06:23 +0200 Subject: [PATCH 002/143] Use - instead of unicode character in license text --- MQ/include/MQ/MQFunctions.h | 2 +- MQ/include/MQ/MQSubsystem.h | 2 +- MQ/src/MQFunctions.cpp | 2 +- MQ/src/MQSubsystem.cpp | 2 +- MQCheck/src/Application.cpp | 2 +- MQWeb/include/MQ/Web/ChannelMapper.h | 2 +- MQWeb/include/MQ/Web/ChannelStatusController.h | 2 +- MQWeb/include/MQ/Web/ChannelStatusMapper.h | 2 +- MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h | 2 +- MQWeb/include/MQ/Web/DenyRequestHandler.h | 2 +- MQWeb/include/MQ/Web/DictionaryCache.h | 2 +- MQWeb/include/MQ/Web/JSONView.h | 2 +- MQWeb/include/MQ/Web/MQMapper.h | 2 +- MQWeb/include/MQ/Web/Mapper.h | 2 +- MQWeb/include/MQ/Web/QueueManagerMapper.h | 2 +- MQWeb/include/MQ/Web/QueueManagerStatusMapper.h | 2 +- MQWeb/include/MQ/Web/TemplateView.h | 2 +- MQWeb/include/MQ/Web/View.h | 2 +- MQWeb/src/ChannelMapper.cpp | 2 +- MQWeb/src/ChannelStatusController.cpp | 2 +- MQWeb/src/ChannelStatusMapper.cpp | 2 +- MQWeb/src/ClusterQueueManagerMapper.cpp | 2 +- MQWeb/src/ControllerRequestHandler.cpp | 2 +- MQWeb/src/DenyRequestHandler.cpp | 2 +- MQWeb/src/Dictionary.cpp | 2 +- MQWeb/src/DictionaryCache.cpp | 2 +- MQWeb/src/JSONView.cpp | 2 +- MQWeb/src/MQMapper.cpp | 2 +- MQWeb/src/MultiView.cpp | 2 +- MQWeb/src/QueueManagerMapper.cpp | 2 +- MQWeb/src/QueueManagerStatusMapper.cpp | 2 +- MQWeb/src/TemplateView.cpp | 2 +- MQWeb/src/View.cpp | 2 +- 33 files changed, 33 insertions(+), 33 deletions(-) diff --git a/MQ/include/MQ/MQFunctions.h b/MQ/include/MQ/MQFunctions.h index ec2f58b..089fd8c 100644 --- a/MQ/include/MQ/MQFunctions.h +++ b/MQ/include/MQ/MQFunctions.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQ/include/MQ/MQSubsystem.h b/MQ/include/MQ/MQSubsystem.h index d96e08c..f3548bd 100644 --- a/MQ/include/MQ/MQSubsystem.h +++ b/MQ/include/MQ/MQSubsystem.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQ/src/MQFunctions.cpp b/MQ/src/MQFunctions.cpp index a86fae7..c541783 100644 --- a/MQ/src/MQFunctions.cpp +++ b/MQ/src/MQFunctions.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQ/src/MQSubsystem.cpp b/MQ/src/MQSubsystem.cpp index cec4487..6cc88d1 100644 --- a/MQ/src/MQSubsystem.cpp +++ b/MQ/src/MQSubsystem.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQCheck/src/Application.cpp b/MQCheck/src/Application.cpp index 76fc639..2a6be54 100644 --- a/MQCheck/src/Application.cpp +++ b/MQCheck/src/Application.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQCheck - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/ChannelMapper.h b/MQWeb/include/MQ/Web/ChannelMapper.h index 0cbfbb3..3b15625 100644 --- a/MQWeb/include/MQ/Web/ChannelMapper.h +++ b/MQWeb/include/MQ/Web/ChannelMapper.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/ChannelStatusController.h b/MQWeb/include/MQ/Web/ChannelStatusController.h index 8234625..8846f45 100644 --- a/MQWeb/include/MQ/Web/ChannelStatusController.h +++ b/MQWeb/include/MQ/Web/ChannelStatusController.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/ChannelStatusMapper.h b/MQWeb/include/MQ/Web/ChannelStatusMapper.h index 8e74a07..ff025b9 100644 --- a/MQWeb/include/MQ/Web/ChannelStatusMapper.h +++ b/MQWeb/include/MQ/Web/ChannelStatusMapper.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h b/MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h index 12dcbff..532a577 100644 --- a/MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h +++ b/MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/DenyRequestHandler.h b/MQWeb/include/MQ/Web/DenyRequestHandler.h index ae254df..1093006 100644 --- a/MQWeb/include/MQ/Web/DenyRequestHandler.h +++ b/MQWeb/include/MQ/Web/DenyRequestHandler.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/DictionaryCache.h b/MQWeb/include/MQ/Web/DictionaryCache.h index 813ac0d..7af49b3 100644 --- a/MQWeb/include/MQ/Web/DictionaryCache.h +++ b/MQWeb/include/MQ/Web/DictionaryCache.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/JSONView.h b/MQWeb/include/MQ/Web/JSONView.h index bda8c77..ab38e6f 100644 --- a/MQWeb/include/MQ/Web/JSONView.h +++ b/MQWeb/include/MQ/Web/JSONView.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/MQMapper.h b/MQWeb/include/MQ/Web/MQMapper.h index 315c8af..bf383ef 100644 --- a/MQWeb/include/MQ/Web/MQMapper.h +++ b/MQWeb/include/MQ/Web/MQMapper.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/Mapper.h b/MQWeb/include/MQ/Web/Mapper.h index 986f95a..4ae4915 100644 --- a/MQWeb/include/MQ/Web/Mapper.h +++ b/MQWeb/include/MQ/Web/Mapper.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/QueueManagerMapper.h b/MQWeb/include/MQ/Web/QueueManagerMapper.h index 54a012e..085ebf9 100644 --- a/MQWeb/include/MQ/Web/QueueManagerMapper.h +++ b/MQWeb/include/MQ/Web/QueueManagerMapper.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h b/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h index 74a0a94..7d177d0 100644 --- a/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h +++ b/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/TemplateView.h b/MQWeb/include/MQ/Web/TemplateView.h index 89a5d55..469261e 100644 --- a/MQWeb/include/MQ/Web/TemplateView.h +++ b/MQWeb/include/MQ/Web/TemplateView.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/include/MQ/Web/View.h b/MQWeb/include/MQ/Web/View.h index 3e0abca..7a0b067 100644 --- a/MQWeb/include/MQ/Web/View.h +++ b/MQWeb/include/MQ/Web/View.h @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/ChannelMapper.cpp b/MQWeb/src/ChannelMapper.cpp index b12b47f..f7ad6d7 100644 --- a/MQWeb/src/ChannelMapper.cpp +++ b/MQWeb/src/ChannelMapper.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index 0c60949..1ee7316 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/ChannelStatusMapper.cpp b/MQWeb/src/ChannelStatusMapper.cpp index 726cd08..453aa06 100644 --- a/MQWeb/src/ChannelStatusMapper.cpp +++ b/MQWeb/src/ChannelStatusMapper.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/ClusterQueueManagerMapper.cpp b/MQWeb/src/ClusterQueueManagerMapper.cpp index 50e0d11..27ac530 100644 --- a/MQWeb/src/ClusterQueueManagerMapper.cpp +++ b/MQWeb/src/ClusterQueueManagerMapper.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index a606e1e..fefeaa2 100644 --- a/MQWeb/src/ControllerRequestHandler.cpp +++ b/MQWeb/src/ControllerRequestHandler.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/DenyRequestHandler.cpp b/MQWeb/src/DenyRequestHandler.cpp index 8fe095f..79da1ca 100644 --- a/MQWeb/src/DenyRequestHandler.cpp +++ b/MQWeb/src/DenyRequestHandler.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/Dictionary.cpp b/MQWeb/src/Dictionary.cpp index da71d5e..36de564 100644 --- a/MQWeb/src/Dictionary.cpp +++ b/MQWeb/src/Dictionary.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/DictionaryCache.cpp b/MQWeb/src/DictionaryCache.cpp index 50c9fa2..093a275 100644 --- a/MQWeb/src/DictionaryCache.cpp +++ b/MQWeb/src/DictionaryCache.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/JSONView.cpp b/MQWeb/src/JSONView.cpp index 4e18340..dfc9ea7 100644 --- a/MQWeb/src/JSONView.cpp +++ b/MQWeb/src/JSONView.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index 05b40b4..d28958b 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/MultiView.cpp b/MQWeb/src/MultiView.cpp index a1e10f5..1c82dfb 100644 --- a/MQWeb/src/MultiView.cpp +++ b/MQWeb/src/MultiView.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/QueueManagerMapper.cpp b/MQWeb/src/QueueManagerMapper.cpp index 5f14bc8..24752d6 100644 --- a/MQWeb/src/QueueManagerMapper.cpp +++ b/MQWeb/src/QueueManagerMapper.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/QueueManagerStatusMapper.cpp b/MQWeb/src/QueueManagerStatusMapper.cpp index 0f5d054..deeed3d 100644 --- a/MQWeb/src/QueueManagerStatusMapper.cpp +++ b/MQWeb/src/QueueManagerStatusMapper.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/TemplateView.cpp b/MQWeb/src/TemplateView.cpp index 952d836..605f620 100644 --- a/MQWeb/src/TemplateView.cpp +++ b/MQWeb/src/TemplateView.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the diff --git a/MQWeb/src/View.cpp b/MQWeb/src/View.cpp index 4c3745e..4c56c1a 100644 --- a/MQWeb/src/View.cpp +++ b/MQWeb/src/View.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or - as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the From 9bb0c02871d3a6ff0c5dfa3bf2be527ca23c3ee3 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 8 Jul 2014 17:20:23 +0200 Subject: [PATCH 003/143] Remove unneed #include statement --- MQWeb/src/ChannelController.cpp | 1 - MQWeb/src/ChannelStatusController.cpp | 1 - MQWeb/src/ClusterQueueManagerController.cpp | 1 - MQWeb/src/ListenerController.cpp | 1 - 4 files changed, 4 deletions(-) diff --git a/MQWeb/src/ChannelController.cpp b/MQWeb/src/ChannelController.cpp index 99afc6c..8b65b96 100644 --- a/MQWeb/src/ChannelController.cpp +++ b/MQWeb/src/ChannelController.cpp @@ -18,7 +18,6 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ -#include "MQ/Web/MQController.h" #include "MQ/Web/ChannelController.h" #include "MQ/Web/ChannelMapper.h" #include "MQ/Web/JSONView.h" diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index 1ee7316..8b26760 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -18,7 +18,6 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ -#include "MQ/Web/MQController.h" #include "MQ/Web/ChannelStatusController.h" #include "MQ/Web/ChannelStatusMapper.h" #include "MQ/Web/JSONView.h" diff --git a/MQWeb/src/ClusterQueueManagerController.cpp b/MQWeb/src/ClusterQueueManagerController.cpp index 6575505..b71453d 100644 --- a/MQWeb/src/ClusterQueueManagerController.cpp +++ b/MQWeb/src/ClusterQueueManagerController.cpp @@ -18,7 +18,6 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ -#include "MQ/Web/MQController.h" #include "MQ/Web/ClusterQueueManagerController.h" #include "MQ/Web/ClusterQueueManagerMapper.h" #include "MQ/Web/JSONView.h" diff --git a/MQWeb/src/ListenerController.cpp b/MQWeb/src/ListenerController.cpp index a8fae57..fcb030d 100644 --- a/MQWeb/src/ListenerController.cpp +++ b/MQWeb/src/ListenerController.cpp @@ -18,7 +18,6 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ -#include "MQ/Web/ListenerController.h" #include "MQ/Web/ListenerMapper.h" #include "MQ/Web/JSONView.h" From a7ee7a443a635b5125b5a12544a3d3bbe1d36c2b Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 8 Jul 2014 17:22:00 +0200 Subject: [PATCH 004/143] Remove #include form HTLMForm --- MQWeb/src/QueueController.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index ad4219d..2257361 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -18,8 +18,6 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ -#include "Poco/Net/HTMLForm.h" - #include "MQ/Web/QueueController.h" #include "MQ/Web/QueueMapper.h" #include "MQ/Web/JSONView.h" From fdfcd38e9b37bd4981ce0eff63c4eadaaa10c35a Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 8 Jul 2014 19:06:39 +0200 Subject: [PATCH 005/143] Removed one #include statement to much ... --- MQWeb/src/ListenerController.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MQWeb/src/ListenerController.cpp b/MQWeb/src/ListenerController.cpp index fcb030d..a8fae57 100644 --- a/MQWeb/src/ListenerController.cpp +++ b/MQWeb/src/ListenerController.cpp @@ -18,6 +18,7 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ +#include "MQ/Web/ListenerController.h" #include "MQ/Web/ListenerMapper.h" #include "MQ/Web/JSONView.h" From 7abe8f047ae49c74df1afa732073952175e76411 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 8 Jul 2014 21:22:51 +0200 Subject: [PATCH 006/143] Add addParameter for byte string --- MQ/include/MQ/PCF.h | 3 +++ MQ/src/PCF.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/MQ/include/MQ/PCF.h b/MQ/include/MQ/PCF.h index ff630b5..e9b01ce 100644 --- a/MQ/include/MQ/PCF.h +++ b/MQ/include/MQ/PCF.h @@ -56,6 +56,9 @@ class PCF : public Message void addParameter(MQLONG parameter, MQLONG value); /// Add a numeric parameter. + void addParameter(MQLONG parameter, BufferPtr buffer); + /// Add a byte string parameter. + void addParameterList(MQLONG parameter, MQLONG *values); /// Add a numeric list parameter. diff --git a/MQ/src/PCF.cpp b/MQ/src/PCF.cpp index 94c9059..9cb40de 100644 --- a/MQ/src/PCF.cpp +++ b/MQ/src/PCF.cpp @@ -256,6 +256,20 @@ void PCF::addParameter(MQLONG parameter, MQLONG value) header->ParameterCount++; } +void PCF::addParameter(MQLONG parameter, BufferPtr value) +{ + MQLONG structLength = ((MQCFST_STRUC_LENGTH_FIXED + value->sizeBytes()) / 4 + 1) * 4; + _pointers[parameter] = buffer().size(); + buffer().resize(buffer().size() + structLength); + MQCFBS* pcfParam = (MQCFBS*) &buffer()[_pointers[parameter]]; + pcfParam->Type = MQCFT_BYTE_STRING; + pcfParam->StrucLength = structLength; + pcfParam->Parameter = parameter; + pcfParam->StringLength = value->sizeBytes(); + memcpy(pcfParam->String, value->begin(), pcfParam->StringLength); + MQCFH* header = (MQCFH*) (MQBYTE*) &buffer()[0]; + header->ParameterCount++; +} void PCF::addParameterList(MQLONG parameter, MQLONG *values) { From 845c807ebc21ae1fcd83179a793691fb9ef71f55 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 8 Jul 2014 21:23:30 +0200 Subject: [PATCH 007/143] Add controller for connections --- MQWeb/include/MQ/Web/ConnectionController.h | 72 +++++++++++++ MQWeb/include/MQ/Web/ConnectionMapper.h | 60 +++++++++++ MQWeb/src/ConnectionController.cpp | 61 +++++++++++ MQWeb/src/ConnectionMapper.cpp | 109 ++++++++++++++++++++ MQWeb/src/ControllerRequestHandler.cpp | 2 + test/connection.py | 20 ++++ 6 files changed, 324 insertions(+) create mode 100644 MQWeb/include/MQ/Web/ConnectionController.h create mode 100644 MQWeb/include/MQ/Web/ConnectionMapper.h create mode 100644 MQWeb/src/ConnectionController.cpp create mode 100644 MQWeb/src/ConnectionMapper.cpp create mode 100644 test/connection.py diff --git a/MQWeb/include/MQ/Web/ConnectionController.h b/MQWeb/include/MQ/Web/ConnectionController.h new file mode 100644 index 0000000..a5bdb49 --- /dev/null +++ b/MQWeb/include/MQ/Web/ConnectionController.h @@ -0,0 +1,72 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_ConnectionController_h +#define _MQWeb_ConnectionController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class ConnectionController : public MQController + /// Controller that shows the details of a connection +{ +public: + ConnectionController(); + /// Constructor + + virtual ~ConnectionController(); + /// Destructor + + void inquire(); + /// Action inquire. Inquire the connections and returns the details in JSON format. + /// URL: + /// connection/inquire/ + /// connection/inquire// + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// connections : An array with all matching connections. This is always an array (even when a connectionId is passed in the URI path). + /// When an MQ error occurs there will be no queues property. + /// error: An object describing the MQ error (only returned on error). + + virtual const std::map& getActions() const; + /// Returns all available actions. + +private: +}; + + +inline const Controller::ActionMap& ConnectionController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&ConnectionController::inquire)) + ; + return actions; +} + + +}} // Namespace MQ::Web + +#endif // _MQWeb_ConnectionController_h diff --git a/MQWeb/include/MQ/Web/ConnectionMapper.h b/MQWeb/include/MQ/Web/ConnectionMapper.h new file mode 100644 index 0000000..bffa088 --- /dev/null +++ b/MQWeb/include/MQ/Web/ConnectionMapper.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQWeb_ConnectionMapper_H +#define _MQWeb_ConnectionMapper_H + +#include "MQ/Web/MQMapper.h" + +namespace MQ { +namespace Web { + +class ConnectionMapper : public MQMapper + /// Maps channel object to/from Websphere MQ +{ +public: + + ConnectionMapper(CommandServer& commandServer); + /// Constructor + + virtual ~ConnectionMapper(); + /// Destructor + + void change(const Poco::JSON::Object::Ptr&obj); + /// Not implemented. + + void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Not implemented. + + void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Not implemented. + + Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + /// Implements the inquire connection command. + +private: + + ConnectionMapper(const ConnectionMapper&); + +}; + +}} // Namespace MQ::Web + +#endif // _MQWeb_ConnectionMapper_H diff --git a/MQWeb/src/ConnectionController.cpp b/MQWeb/src/ConnectionController.cpp new file mode 100644 index 0000000..37d0412 --- /dev/null +++ b/MQWeb/src/ConnectionController.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/ConnectionController.h" +#include "MQ/Web/ConnectionMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + +ConnectionController::ConnectionController() : MQController() +{ +} + + +ConnectionController::~ConnectionController() +{ + +} + + +void ConnectionController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a connection id and will result in inquiring + // only that connection. + if ( parameters.size() > 1 ) + { + filter->set("id", parameters[1]); + } + + ConnectionMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("connections", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/ConnectionMapper.cpp b/MQWeb/src/ConnectionMapper.cpp new file mode 100644 index 0000000..57f1fc9 --- /dev/null +++ b/MQWeb/src/ConnectionMapper.cpp @@ -0,0 +1,109 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/ConnectionMapper.h" +#include "MQ/MQException.h" + +#include "Poco/JSON/Object.h" +#include "Poco/HexBinaryDecoder.h" + +namespace MQ { +namespace Web { + + +ConnectionMapper::ConnectionMapper(CommandServer& commandServer) : MQMapper(commandServer, "Connection") +{ +} + +ConnectionMapper::~ConnectionMapper() +{ +} + + +void ConnectionMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not implemented +} + + +void ConnectionMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not implemented +} + + +void ConnectionMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not implemented +} + + +Poco::JSON::Array::Ptr ConnectionMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr connections = new Poco::JSON::Array(); + + PCF::Ptr inquireConnections = _commandServer.createCommand(MQCMD_INQUIRE_CONNECTION); + + if ( filter->has("id") ) + { + std::string hexId = filter->get("id"); + BufferPtr id = new Buffer(hexId.size() / 2); + + std::istringstream iss(hexId); + Poco::HexBinaryDecoder decoder(iss); + int c = decoder.get(); + int i = 0; + while (c != -1 && i < id->size()) + { + id[i++] = (unsigned char) c; + c = decoder.get(); + } + + inquireConnections->addParameter(MQBACF_CONNECTION_ID, id); + } + else + { + BufferPtr id = new Buffer(0); // Empty buffer + inquireConnections->addParameter(MQBACF_GENERIC_CONNECTION_ID, id); + } + + PCF::Vector commandResponse; + _commandServer.sendCommand(inquireConnections, commandResponse); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + Poco::JSON::Object::Ptr connection = new Poco::JSON::Object(); + connections->add(connection); + + dictionary()->mapToJSON(**it, connection); + } + + return connections; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index fefeaa2..c63a9c8 100644 --- a/MQWeb/src/ControllerRequestHandler.cpp +++ b/MQWeb/src/ControllerRequestHandler.cpp @@ -25,6 +25,7 @@ #include "MQ/Web/QueueManagerStatusController.h" #include "MQ/Web/ChannelController.h" #include "MQ/Web/ChannelStatusController.h" +#include "MQ/Web/ConnectionController.h" #include "MQ/Web/MessageController.h" #include "MQ/Web/ListenerController.h" #include "MQ/Web/ListenerStatusController.h" @@ -112,6 +113,7 @@ void ControllerRequestHandler::registerControllers() _controllerFactory.registerClass("listener"); _controllerFactory.registerClass("lsstatus"); _controllerFactory.registerClass("clusqmgr"); + _controllerFactory.registerClass("conn"); } diff --git a/test/connection.py b/test/connection.py new file mode 100644 index 0000000..c6d9514 --- /dev/null +++ b/test/connection.py @@ -0,0 +1,20 @@ +import unittest +from testbase import MQWebTest + +class TestConnectionActions(MQWebTest): + + def testInquire(self): + + data = self.getJSON('/api/conn/inquire/' + self.qmgr) + + self.assertFalse('mqweb' not in data, 'No mqweb data returned') + + if 'error' in data: + self.assertFalse(True, 'Received a WebSphere MQ error:' + str(data['error']['reason']['code'])) + + self.assertFalse('connections' not in data, 'No connections returned') + + self.assertTrue(self.checkIds(data['connections'][0]), 'There are unmapped Websphere MQ attributes') + +suite = unittest.TestLoader().loadTestsFromTestCase(TestConnectionActions) +unittest.TextTestRunner(verbosity=2).run(suite) From 274a283e51c7e15b702ed29c448e67cbcd51ad48 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 9 Jul 2014 14:15:06 +0200 Subject: [PATCH 008/143] Add Namelist controller (nl) --- MQDictionary/src/Application.cpp | 23 ++++++ MQWeb/include/MQ/Web/NamelistController.h | 79 +++++++++++++++++++ MQWeb/include/MQ/Web/NamelistMapper.h | 60 ++++++++++++++ MQWeb/src/ControllerRequestHandler.cpp | 12 +-- MQWeb/src/NamelistController.cpp | 67 ++++++++++++++++ MQWeb/src/NamelistMapper.cpp | 96 +++++++++++++++++++++++ test/nl.py | 20 +++++ 7 files changed, 352 insertions(+), 5 deletions(-) create mode 100644 MQWeb/include/MQ/Web/NamelistController.h create mode 100644 MQWeb/include/MQ/Web/NamelistMapper.h create mode 100644 MQWeb/src/NamelistController.cpp create mode 100644 MQWeb/src/NamelistMapper.cpp create mode 100644 test/nl.py diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 0eb2c67..913061e 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -1254,6 +1254,12 @@ Dictionary clusterQueueManagerDictionary = Dictionary() Dictionary connectionDictionary = Dictionary() (MQIA_APPL_TYPE, "") + (MQBACF_CONNECTION_ID, "ConnectionId") + (MQIACF_CONN_INFO_TYPE, "ConnInfoType", DisplayMapInitializer + (MQIACF_CONN_INFO_CONN, "Generic Information") + (MQIACF_CONN_INFO_HANDLE, "Connection Information") + ) + (MQBACF_GENERIC_CONNECTION_ID, "GenericConnectionId") // Extended Response (MQBACF_RESPONSE_ID, "ResponseID") (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") @@ -2236,6 +2242,22 @@ Dictionary reasonDictionary = Dictionary() ) ; +Dictionary namelistDictionary = Dictionary() + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) + (MQIA_NAME_COUNT, "NameCount") + (MQCA_NAMELIST_DESC, "NamelistDesc") + (MQCA_NAMELIST_NAME) + (MQIA_NAMELIST_TYPE, "NamelistType", DisplayMapInitializer + (MQNT_NONE, "None") + (MQNT_Q, "Queue") + (MQNT_CLUSTER, "Cluster") + (MQNT_AUTH_INFO, "AuthInfo") + ) + (MQCA_NAMES, "Names") + (MQIA_QSG_DISP) +; + class MQDictionary : public Poco::Util::Application { public: @@ -2345,6 +2367,7 @@ int main(const std::vector& args) store(session, ++oid, "Topic", topicDictionary); store(session, ++oid, "Event", eventDictionary); store(session, ++oid, "Reason", reasonDictionary); + store(session, ++oid, "Namelist", namelistDictionary); return Application::EXIT_OK; } diff --git a/MQWeb/include/MQ/Web/NamelistController.h b/MQWeb/include/MQ/Web/NamelistController.h new file mode 100644 index 0000000..defce21 --- /dev/null +++ b/MQWeb/include/MQ/Web/NamelistController.h @@ -0,0 +1,79 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_NamelistController_h +#define _MQWeb_NamelistController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class NamelistController : public MQController + /// Controller that shows the details of a channel +{ +public: + NamelistController(); + /// Constructor + + virtual ~NamelistController(); + /// Destructor + + void inquire(); + /// Action inquire. Inquire the namelists and returns the details in JSON format. + /// URL: + /// nl/inquire/ + /// nl/inquire// + /// nl/inquire/?namelistName=MQWEB* + /// + /// Query Parameters: + /// namelistName: Name of the namelist (* is default). + /// excludeSystem: When 'true', don't return system namelists + /// + /// Query parameters are ignored when a namelistName is passed in the URI path. + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// namelists : An array with all matching namelists. This is always an array (even when a namelistname is passed in the URI path). + /// When an MQ error occurs there will be no namelists property. + /// error: An object describing the MQ error (only returned on error). + + virtual const std::map& getActions() const; + /// Returns all available actions. + +private: +}; + + +inline const Controller::ActionMap& NamelistController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&NamelistController::inquire)) + ; + return actions; +} + + +}} // Namespace MQ::Web + +#endif // _MQWeb_NamelistController_h diff --git a/MQWeb/include/MQ/Web/NamelistMapper.h b/MQWeb/include/MQ/Web/NamelistMapper.h new file mode 100644 index 0000000..2035446 --- /dev/null +++ b/MQWeb/include/MQ/Web/NamelistMapper.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQWeb_NamelistMapper_H +#define _MQWeb_NamelistMapper_H + +#include "MQ/Web/MQMapper.h" + +namespace MQ { +namespace Web { + +class NamelistMapper : public MQMapper + /// Maps channel object to/from Websphere MQ +{ +public: + + NamelistMapper(CommandServer& commandServer); + /// Constructor + + virtual ~NamelistMapper(); + /// Destructor + + void change(const Poco::JSON::Object::Ptr&obj); + /// Implements the change channel command. Not implemented yet. + + void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the create channel command. Not implemented yet. + + void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the copy channel command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + /// Implements the inquire channel command. + +private: + + NamelistMapper(const NamelistMapper&); + +}; + +}} // Namespace MQ::Web + +#endif // _MQWeb_NamelistMapper_H diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index c63a9c8..f403f74 100644 --- a/MQWeb/src/ControllerRequestHandler.cpp +++ b/MQWeb/src/ControllerRequestHandler.cpp @@ -20,16 +20,17 @@ */ #include "MQ/Web/ControllerRequestHandler.h" #include "MQ/Web/WebController.h" -#include "MQ/Web/QueueController.h" -#include "MQ/Web/QueueManagerController.h" -#include "MQ/Web/QueueManagerStatusController.h" #include "MQ/Web/ChannelController.h" #include "MQ/Web/ChannelStatusController.h" +#include "MQ/Web/ClusterQueueManagerController.h" #include "MQ/Web/ConnectionController.h" -#include "MQ/Web/MessageController.h" #include "MQ/Web/ListenerController.h" #include "MQ/Web/ListenerStatusController.h" -#include "MQ/Web/ClusterQueueManagerController.h" +#include "MQ/Web/MessageController.h" +#include "MQ/Web/NamelistController.h" +#include "MQ/Web/QueueController.h" +#include "MQ/Web/QueueManagerController.h" +#include "MQ/Web/QueueManagerStatusController.h" #include "Poco/URI.h" @@ -114,6 +115,7 @@ void ControllerRequestHandler::registerControllers() _controllerFactory.registerClass("lsstatus"); _controllerFactory.registerClass("clusqmgr"); _controllerFactory.registerClass("conn"); + _controllerFactory.registerClass("nl"); } diff --git a/MQWeb/src/NamelistController.cpp b/MQWeb/src/NamelistController.cpp new file mode 100644 index 0000000..0cfc011 --- /dev/null +++ b/MQWeb/src/NamelistController.cpp @@ -0,0 +1,67 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/NamelistController.h" +#include "MQ/Web/NamelistMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + +NamelistController::NamelistController() : MQController() +{ +} + + +NamelistController::~NamelistController() +{ + +} + + +void NamelistController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a namelistname and will result in inquiring + // only that namelist. + if ( parameters.size() > 1 ) + { + filter->set("name", parameters[1]); + } + else + { + std::string namelistNameField = form().get("namelistName", "*"); + filter->set("name", namelistNameField.empty() ? "*" : namelistNameField); + filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + } + + NamelistMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("namelists", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/NamelistMapper.cpp b/MQWeb/src/NamelistMapper.cpp new file mode 100644 index 0000000..011dfb5 --- /dev/null +++ b/MQWeb/src/NamelistMapper.cpp @@ -0,0 +1,96 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/NamelistMapper.h" +#include "MQ/MQException.h" + +#include "Poco/JSON/Object.h" + +namespace MQ { +namespace Web { + + +NamelistMapper::NamelistMapper(CommandServer& commandServer) : MQMapper(commandServer, "Namelist") +{ +} + +NamelistMapper::~NamelistMapper() +{ +} + + +void NamelistMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void NamelistMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void NamelistMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr NamelistMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr namelists = new Poco::JSON::Array(); + + PCF::Ptr inquireNamelist = _commandServer.createCommand(MQCMD_INQUIRE_NAMELIST); + + inquireNamelist->addParameter(MQCA_NAMELIST_NAME, filter->optValue("name", "*")); + + PCF::Vector commandResponse; + _commandServer.sendCommand(inquireNamelist, commandResponse); + + bool excludeSystem = filter->optValue("excludeSystem", false); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + std::string namelistName = (*it)->getParameterString(MQCA_NAMELIST_NAME); + if ( excludeSystem + && namelistName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } + + Poco::JSON::Object::Ptr namelist = new Poco::JSON::Object(); + namelists->add(namelist); + + dictionary()->mapToJSON(**it, namelist); + } + + return namelists; +} + +}} // Namespace MQ::Web diff --git a/test/nl.py b/test/nl.py new file mode 100644 index 0000000..dd1de69 --- /dev/null +++ b/test/nl.py @@ -0,0 +1,20 @@ +import unittest +from testbase import MQWebTest + +class TestNamelistActions(MQWebTest): + + def testInquire(self): + + data = self.getJSON('/api/nl/inquire/' + self.qmgr) + + self.assertFalse('mqweb' not in data, 'No mqweb data returned') + + if 'error' in data: + self.assertFalse(True, 'Received a WebSphere MQ error:' + str(data['error']['reason']['code'])) + + self.assertFalse('namelists' not in data, 'No namelists returned') + + self.assertTrue(self.checkIds(data['namelists'][0]), 'There are unmapped Websphere MQ attributes') + +suite = unittest.TestLoader().loadTestsFromTestCase(TestNamelistActions) +unittest.TextTestRunner(verbosity=2).run(suite) From 5eae5f038442376cfcf64d5899ce3a0d1ef80d61 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 9 Jul 2014 18:52:49 +0200 Subject: [PATCH 009/143] Add process controller --- MQDictionary/src/Application.cpp | 13 +++ MQWeb/include/MQ/Web/ChannelController.h | 6 +- MQWeb/include/MQ/Web/NamelistController.h | 2 +- MQWeb/include/MQ/Web/ProcessController.h | 79 +++++++++++++++++++ MQWeb/include/MQ/Web/ProcessMapper.h | 60 ++++++++++++++ MQWeb/src/ControllerRequestHandler.cpp | 2 + MQWeb/src/ProcessController.cpp | 67 ++++++++++++++++ MQWeb/src/ProcessMapper.cpp | 96 +++++++++++++++++++++++ test/process.py | 20 +++++ 9 files changed, 341 insertions(+), 4 deletions(-) create mode 100644 MQWeb/include/MQ/Web/ProcessController.h create mode 100644 MQWeb/include/MQ/Web/ProcessMapper.h create mode 100644 MQWeb/src/ProcessController.cpp create mode 100644 MQWeb/src/ProcessMapper.cpp create mode 100644 test/process.py diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 913061e..e6355a5 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -2258,6 +2258,18 @@ Dictionary namelistDictionary = Dictionary() (MQIA_QSG_DISP) ; +Dictionary processDictionary = Dictionary() + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) + (MQCA_APPL_ID, "ApplId") + (MQIA_APPL_TYPE) + (MQCA_ENV_DATA, "EnvData") + (MQCA_PROCESS_DESC, "ProcessDesc") + (MQCA_PROCESS_NAME) + (MQIA_QSG_DISP) + (MQCA_USER_DATA, "UserData") +; + class MQDictionary : public Poco::Util::Application { public: @@ -2368,6 +2380,7 @@ int main(const std::vector& args) store(session, ++oid, "Event", eventDictionary); store(session, ++oid, "Reason", reasonDictionary); store(session, ++oid, "Namelist", namelistDictionary); + store(session, ++oid, "Process", processDictionary); return Application::EXIT_OK; } diff --git a/MQWeb/include/MQ/Web/ChannelController.h b/MQWeb/include/MQ/Web/ChannelController.h index 6d4d7ec..e18eb6f 100644 --- a/MQWeb/include/MQ/Web/ChannelController.h +++ b/MQWeb/include/MQ/Web/ChannelController.h @@ -51,12 +51,12 @@ class ChannelController : public MQController /// Possible values: /// excludeSystem: When 'true', don't return system channels /// - /// Query parameters are ignored when a queueName is passed in the URI path. + /// Query parameters are ignored when a channelName is passed in the URI path. /// /// The returned JSON object can contain following properties: /// mqweb : An object with information about the MQWeb application and request. - /// queues : An array with all matching queues. This is always an array (even when a queuename is passed in the URI path). - /// When an MQ error occurs there will be no queues property. + /// queues : An array with all matching channels. This is always an array (even when a channelname is passed in the URI path). + /// When an MQ error occurs there will be no channels property. /// error: An object describing the MQ error (only returned on error). virtual const std::map& getActions() const; diff --git a/MQWeb/include/MQ/Web/NamelistController.h b/MQWeb/include/MQ/Web/NamelistController.h index defce21..27e2f9e 100644 --- a/MQWeb/include/MQ/Web/NamelistController.h +++ b/MQWeb/include/MQ/Web/NamelistController.h @@ -29,7 +29,7 @@ namespace MQ { namespace Web { class NamelistController : public MQController - /// Controller that shows the details of a channel + /// Controller that shows the details of a namelist { public: NamelistController(); diff --git a/MQWeb/include/MQ/Web/ProcessController.h b/MQWeb/include/MQ/Web/ProcessController.h new file mode 100644 index 0000000..c1cd890 --- /dev/null +++ b/MQWeb/include/MQ/Web/ProcessController.h @@ -0,0 +1,79 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_ProcessController_h +#define _MQWeb_ProcessController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class ProcessController : public MQController + /// Controller that shows the details of a process +{ +public: + ProcessController(); + /// Constructor + + virtual ~ProcessController(); + /// Destructor + + void inquire(); + /// Action inquire. Inquire the processes and returns the details in JSON format. + /// URL: + /// process/inquire/ + /// process/inquire// + /// process/inquire/?processName=MQWEB* + /// + /// Query Parameters: + /// processName: Name of the process (* is default). + /// excludeSystem: When 'true', don't return system processes + /// + /// Query parameters are ignored when a processName is passed in the URI path. + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// processes : An array with all matching processes. This is always an array (even when a processname is passed in the URI path). + /// When an MQ error occurs there will be no processes property. + /// error: An object describing the MQ error (only returned on error). + + virtual const std::map& getActions() const; + /// Returns all available actions. + +private: +}; + + +inline const Controller::ActionMap& ProcessController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&ProcessController::inquire)) + ; + return actions; +} + + +}} // Namespace MQ::Web + +#endif // _MQWeb_ProcessController_h diff --git a/MQWeb/include/MQ/Web/ProcessMapper.h b/MQWeb/include/MQ/Web/ProcessMapper.h new file mode 100644 index 0000000..f3c01c7 --- /dev/null +++ b/MQWeb/include/MQ/Web/ProcessMapper.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQWeb_ProcessMapper_H +#define _MQWeb_ProcessMapper_H + +#include "MQ/Web/MQMapper.h" + +namespace MQ { +namespace Web { + +class ProcessMapper : public MQMapper + /// Maps process object to/from Websphere MQ +{ +public: + + ProcessMapper(CommandServer& commandServer); + /// Constructor + + virtual ~ProcessMapper(); + /// Destructor + + void change(const Poco::JSON::Object::Ptr&obj); + /// Implements the change channel command. Not implemented yet. + + void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the create channel command. Not implemented yet. + + void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the copy channel command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + /// Implements the inquire channel command. + +private: + + ProcessMapper(const ProcessMapper&); + +}; + +}} // Namespace MQ::Web + +#endif // _MQWeb_ProcessMapper_H diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index f403f74..2289ecf 100644 --- a/MQWeb/src/ControllerRequestHandler.cpp +++ b/MQWeb/src/ControllerRequestHandler.cpp @@ -28,6 +28,7 @@ #include "MQ/Web/ListenerStatusController.h" #include "MQ/Web/MessageController.h" #include "MQ/Web/NamelistController.h" +#include "MQ/Web/ProcessController.h" #include "MQ/Web/QueueController.h" #include "MQ/Web/QueueManagerController.h" #include "MQ/Web/QueueManagerStatusController.h" @@ -116,6 +117,7 @@ void ControllerRequestHandler::registerControllers() _controllerFactory.registerClass("clusqmgr"); _controllerFactory.registerClass("conn"); _controllerFactory.registerClass("nl"); + _controllerFactory.registerClass("process"); } diff --git a/MQWeb/src/ProcessController.cpp b/MQWeb/src/ProcessController.cpp new file mode 100644 index 0000000..f70b674 --- /dev/null +++ b/MQWeb/src/ProcessController.cpp @@ -0,0 +1,67 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/ProcessController.h" +#include "MQ/Web/ProcessMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + +ProcessController::ProcessController() : MQController() +{ +} + + +ProcessController::~ProcessController() +{ + +} + + +void ProcessController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a processname and will result in inquiring + // only that process. + if ( parameters.size() > 1 ) + { + filter->set("name", parameters[1]); + } + else + { + std::string processNameField = form().get("processName", "*"); + filter->set("name", processNameField.empty() ? "*" : processNameField); + filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + } + + ProcessMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("processes", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/ProcessMapper.cpp b/MQWeb/src/ProcessMapper.cpp new file mode 100644 index 0000000..8b214de --- /dev/null +++ b/MQWeb/src/ProcessMapper.cpp @@ -0,0 +1,96 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/ProcessMapper.h" +#include "MQ/MQException.h" + +#include "Poco/JSON/Object.h" + +namespace MQ { +namespace Web { + + +ProcessMapper::ProcessMapper(CommandServer& commandServer) : MQMapper(commandServer, "Process") +{ +} + +ProcessMapper::~ProcessMapper() +{ +} + + +void ProcessMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void ProcessMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void ProcessMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr ProcessMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr processes = new Poco::JSON::Array(); + + PCF::Ptr inquireProcess = _commandServer.createCommand(MQCMD_INQUIRE_PROCESS); + + inquireProcess->addParameter(MQCA_PROCESS_NAME, filter->optValue("name", "*")); + + PCF::Vector commandResponse; + _commandServer.sendCommand(inquireProcess, commandResponse); + + bool excludeSystem = filter->optValue("excludeSystem", false); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + std::string processName = (*it)->getParameterString(MQCA_PROCESS_NAME); + if ( excludeSystem + && processName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } + + Poco::JSON::Object::Ptr process = new Poco::JSON::Object(); + processes->add(process); + + dictionary()->mapToJSON(**it, process); + } + + return processes; +} + +}} // Namespace MQ::Web diff --git a/test/process.py b/test/process.py new file mode 100644 index 0000000..f1b3b77 --- /dev/null +++ b/test/process.py @@ -0,0 +1,20 @@ +import unittest +from testbase import MQWebTest + +class TestProcessActions(MQWebTest): + + def testInquire(self): + + data = self.getJSON('/api/process/inquire/' + self.qmgr) + + self.assertFalse('mqweb' not in data, 'No mqweb data returned') + + if 'error' in data: + self.assertFalse(True, 'Received a WebSphere MQ error:' + str(data['error']['reason']['code'])) + + self.assertFalse('processes' not in data, 'No processes returned') + + self.assertTrue(self.checkIds(data['processes'][0]), 'There are unmapped Websphere MQ attributes') + +suite = unittest.TestLoader().loadTestsFromTestCase(TestProcessActions) +unittest.TextTestRunner(verbosity=2).run(suite) From 53cb36ddc62ccc45dd0de85a22db05e13f5cc845 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 9 Jul 2014 21:22:29 +0200 Subject: [PATCH 010/143] Update some comments --- MQWeb/include/MQ/Web/ConnectionMapper.h | 2 +- MQWeb/include/MQ/Web/NamelistMapper.h | 10 +++++----- MQWeb/include/MQ/Web/ProcessMapper.h | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MQWeb/include/MQ/Web/ConnectionMapper.h b/MQWeb/include/MQ/Web/ConnectionMapper.h index bffa088..5421fe9 100644 --- a/MQWeb/include/MQ/Web/ConnectionMapper.h +++ b/MQWeb/include/MQ/Web/ConnectionMapper.h @@ -27,7 +27,7 @@ namespace MQ { namespace Web { class ConnectionMapper : public MQMapper - /// Maps channel object to/from Websphere MQ + /// Maps connection object to/from Websphere MQ { public: diff --git a/MQWeb/include/MQ/Web/NamelistMapper.h b/MQWeb/include/MQ/Web/NamelistMapper.h index 2035446..f94c597 100644 --- a/MQWeb/include/MQ/Web/NamelistMapper.h +++ b/MQWeb/include/MQ/Web/NamelistMapper.h @@ -27,7 +27,7 @@ namespace MQ { namespace Web { class NamelistMapper : public MQMapper - /// Maps channel object to/from Websphere MQ + /// Maps namelist object to/from Websphere MQ { public: @@ -38,16 +38,16 @@ class NamelistMapper : public MQMapper /// Destructor void change(const Poco::JSON::Object::Ptr&obj); - /// Implements the change channel command. Not implemented yet. + /// Implements the change namelist command. Not implemented yet. void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); - /// Implements the create channel command. Not implemented yet. + /// Implements the create namelist command. Not implemented yet. void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); - /// Implements the copy channel command. Not implemented yet. + /// Implements the copy namelist command. Not implemented yet. Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); - /// Implements the inquire channel command. + /// Implements the inquire namelist command. private: diff --git a/MQWeb/include/MQ/Web/ProcessMapper.h b/MQWeb/include/MQ/Web/ProcessMapper.h index f3c01c7..754f174 100644 --- a/MQWeb/include/MQ/Web/ProcessMapper.h +++ b/MQWeb/include/MQ/Web/ProcessMapper.h @@ -38,16 +38,16 @@ class ProcessMapper : public MQMapper /// Destructor void change(const Poco::JSON::Object::Ptr&obj); - /// Implements the change channel command. Not implemented yet. + /// Implements the change process command. Not implemented yet. void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); - /// Implements the create channel command. Not implemented yet. + /// Implements the create process command. Not implemented yet. void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); - /// Implements the copy channel command. Not implemented yet. + /// Implements the copy process command. Not implemented yet. Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); - /// Implements the inquire channel command. + /// Implements the inquire process command. private: From 2311fa9f1032f06b09e948fb0601340dc3d45f06 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 9 Jul 2014 21:22:53 +0200 Subject: [PATCH 011/143] Add inquire service --- MQDictionary/src/Application.cpp | 23 ++++++ MQWeb/include/MQ/Web/ServiceController.h | 79 ++++++++++++++++++++ MQWeb/include/MQ/Web/ServiceMapper.h | 60 +++++++++++++++ MQWeb/src/ControllerRequestHandler.cpp | 2 + MQWeb/src/ServiceController.cpp | 67 +++++++++++++++++ MQWeb/src/ServiceMapper.cpp | 95 ++++++++++++++++++++++++ test/service.py | 20 +++++ 7 files changed, 346 insertions(+) create mode 100644 MQWeb/include/MQ/Web/ServiceController.h create mode 100644 MQWeb/include/MQ/Web/ServiceMapper.h create mode 100644 MQWeb/src/ServiceController.cpp create mode 100644 MQWeb/src/ServiceMapper.cpp create mode 100644 test/service.py diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index e6355a5..a17e1d8 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -2270,6 +2270,28 @@ Dictionary processDictionary = Dictionary() (MQCA_USER_DATA, "UserData") ; +Dictionary serviceDictionary = Dictionary() + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) + (MQCA_SERVICE_DESC, "ServiceDesc") + (MQCA_SERVICE_NAME, "ServiceName") + (MQIA_SERVICE_TYPE, "ServiceType", DisplayMapInitializer + (MQSVC_TYPE_SERVER, "Server") + (MQSVC_TYPE_COMMAND, "Command") + ) + (MQCA_SERVICE_START_ARGS, "StartArguments") + (MQCA_SERVICE_START_COMMAND, "StartCommand") + (MQIA_SERVICE_CONTROL, "StartMode", DisplayMapInitializer + (MQSVC_CONTROL_MANUAL, "Manual") + (MQSVC_CONTROL_Q_MGR, "Qmgr") + (MQSVC_CONTROL_Q_MGR_START, "QmgrStart") + ) + (MQCA_STDERR_DESTINATION, "StderrDestination") + (MQCA_STDOUT_DESTINATION, "StdoutDestination") + (MQCA_SERVICE_STOP_ARGS, "StopArguments") + (MQCA_SERVICE_STOP_COMMAND, "StopCommand") +; + class MQDictionary : public Poco::Util::Application { public: @@ -2381,6 +2403,7 @@ int main(const std::vector& args) store(session, ++oid, "Reason", reasonDictionary); store(session, ++oid, "Namelist", namelistDictionary); store(session, ++oid, "Process", processDictionary); + store(session, ++oid, "Service", serviceDictionary); return Application::EXIT_OK; } diff --git a/MQWeb/include/MQ/Web/ServiceController.h b/MQWeb/include/MQ/Web/ServiceController.h new file mode 100644 index 0000000..286a27a --- /dev/null +++ b/MQWeb/include/MQ/Web/ServiceController.h @@ -0,0 +1,79 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_ServiceController_h +#define _MQWeb_ServiceController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class ServiceController : public MQController + /// Controller that shows the details of a service +{ +public: + ServiceController(); + /// Constructor + + virtual ~ServiceController(); + /// Destructor + + void inquire(); + /// Action inquire. Inquire the services and returns the details in JSON format. + /// URL: + /// service/inquire/ + /// service/inquire// + /// service/inquire/?serviceName=MQWEB* + /// + /// Query Parameters: + /// serviceName: Name of the service (* is default). + /// excludeSystem: When 'true', don't return system channels + /// + /// Query parameters are ignored when a serviceName is passed in the URI path. + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// services : An array with all matching services. This is always an array (even when a servicename is passed in the URI path). + /// When an MQ error occurs there will be no services property. + /// error: An object describing the MQ error (only returned on error). + + virtual const std::map& getActions() const; + /// Returns all available actions. + +private: +}; + + +inline const Controller::ActionMap& ServiceController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&ServiceController::inquire)) + ; + return actions; +} + + +}} // Namespace MQ::Web + +#endif // _MQWeb_ServiceController_h diff --git a/MQWeb/include/MQ/Web/ServiceMapper.h b/MQWeb/include/MQ/Web/ServiceMapper.h new file mode 100644 index 0000000..3a3bf59 --- /dev/null +++ b/MQWeb/include/MQ/Web/ServiceMapper.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQWeb_ServiceMapper_H +#define _MQWeb_ServiceMapper_H + +#include "MQ/Web/MQMapper.h" + +namespace MQ { +namespace Web { + +class ServiceMapper : public MQMapper + /// Maps service object to/from Websphere MQ +{ +public: + + ServiceMapper(CommandServer& commandServer); + /// Constructor + + virtual ~ServiceMapper(); + /// Destructor + + void change(const Poco::JSON::Object::Ptr&obj); + /// Implements the change service command. Not implemented yet. + + void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the create service command. Not implemented yet. + + void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the copy service command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + /// Implements the inquire service command. + +private: + + ServiceMapper(const ServiceMapper&); + +}; + +}} // Namespace MQ::Web + +#endif // _MQWeb_ServiceMapper_H diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index 2289ecf..a5cb81e 100644 --- a/MQWeb/src/ControllerRequestHandler.cpp +++ b/MQWeb/src/ControllerRequestHandler.cpp @@ -32,6 +32,7 @@ #include "MQ/Web/QueueController.h" #include "MQ/Web/QueueManagerController.h" #include "MQ/Web/QueueManagerStatusController.h" +#include "MQ/Web/ServiceController.h" #include "Poco/URI.h" @@ -118,6 +119,7 @@ void ControllerRequestHandler::registerControllers() _controllerFactory.registerClass("conn"); _controllerFactory.registerClass("nl"); _controllerFactory.registerClass("process"); + _controllerFactory.registerClass("service"); } diff --git a/MQWeb/src/ServiceController.cpp b/MQWeb/src/ServiceController.cpp new file mode 100644 index 0000000..43e8c48 --- /dev/null +++ b/MQWeb/src/ServiceController.cpp @@ -0,0 +1,67 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/ServiceController.h" +#include "MQ/Web/ServiceMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + +ServiceController::ServiceController() : MQController() +{ +} + + +ServiceController::~ServiceController() +{ + +} + + +void ServiceController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a servicename and will result in inquiring + // only that serive. + if ( parameters.size() > 1 ) + { + filter->set("name", parameters[1]); + } + else + { + std::string serviceNameField = form().get("serviceName", "*"); + filter->set("name", serviceNameField.empty() ? "*" : serviceNameField); + filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + } + + ServiceMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("services", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/ServiceMapper.cpp b/MQWeb/src/ServiceMapper.cpp new file mode 100644 index 0000000..a820b55 --- /dev/null +++ b/MQWeb/src/ServiceMapper.cpp @@ -0,0 +1,95 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/ServiceMapper.h" +#include "MQ/MQException.h" + +#include "Poco/JSON/Object.h" + +namespace MQ { +namespace Web { + + +ServiceMapper::ServiceMapper(CommandServer& commandServer) : MQMapper(commandServer, "Service") +{ +} + +ServiceMapper::~ServiceMapper() +{ +} + + +void ServiceMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void ServiceMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void ServiceMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr ServiceMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr services = new Poco::JSON::Array(); + + PCF::Ptr inquireService = _commandServer.createCommand(MQCMD_INQUIRE_SERVICE); + + inquireService->addParameter(MQCA_SERVICE_NAME, filter->optValue("name", "*")); + + PCF::Vector commandResponse; + _commandServer.sendCommand(inquireService, commandResponse); + + bool excludeSystem = filter->optValue("excludeSystem", false); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + std::string serviceName = (*it)->getParameterString(MQCA_SERVICE_NAME); + if ( excludeSystem && serviceName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } + + Poco::JSON::Object::Ptr service = new Poco::JSON::Object(); + services->add(service); + + dictionary()->mapToJSON(**it, service); + } + + return services; +} + +}} // Namespace MQ::Web diff --git a/test/service.py b/test/service.py new file mode 100644 index 0000000..5d78f6b --- /dev/null +++ b/test/service.py @@ -0,0 +1,20 @@ +import unittest +from testbase import MQWebTest + +class TestServiceActions(MQWebTest): + + def testInquire(self): + + data = self.getJSON('/api/service/inquire/' + self.qmgr) + + self.assertFalse('mqweb' not in data, 'No mqweb data returned') + + if 'error' in data: + self.assertFalse(True, 'Received a WebSphere MQ error:' + str(data['error']['reason']['code'])) + + self.assertFalse('services' not in data, 'No services returned') + + self.assertTrue(self.checkIds(data['services'][0]), 'There are unmapped Websphere MQ attributes') + +suite = unittest.TestLoader().loadTestsFromTestCase(TestServiceActions) +unittest.TextTestRunner(verbosity=2).run(suite) From 851c7b0378088f5fca531229dffe737217bddbae Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 9 Jul 2014 21:24:19 +0200 Subject: [PATCH 012/143] Update changelog --- ChangeLog.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index eb48784..3714ae3 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,9 @@ +0.0.11 + - Add inquire connection (conn) + - Add inquire namelist (nl) + - Add inquire process (process) + - Add inquire service (service) + 0.0.10 - queueExcludeSystem/queueExcludeTemp renamed into excludeSystem/excludeTemp - channelExcludeSystem renamed into excludeSystem From 53411a5d42a415ee92d1c5c7f3408cf2a17f6c64 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 6 Aug 2014 16:05:36 +0200 Subject: [PATCH 013/143] Working on Queue Status and Authenthication Information --- MQDictionary/src/Application.cpp | 18 +++ .../Web/AuthenticationInformationController.h | 79 ++++++++++++ .../MQ/Web/AuthenticationInformationMapper.h | 60 +++++++++ MQWeb/include/MQ/Web/QueueStatusController.h | 82 ++++++++++++ .../AuthenticationInformationController.cpp | 73 +++++++++++ MQWeb/src/AuthenticationInformationMapper.cpp | 94 ++++++++++++++ MQWeb/src/ControllerRequestHandler.cpp | 4 + MQWeb/src/QueueStatusController.cpp | 75 +++++++++++ MQWeb/src/QueueStatusMapper.cpp | 120 ++++++++++++++++++ 9 files changed, 605 insertions(+) create mode 100644 MQWeb/include/MQ/Web/AuthenticationInformationController.h create mode 100644 MQWeb/include/MQ/Web/AuthenticationInformationMapper.h create mode 100644 MQWeb/include/MQ/Web/QueueStatusController.h create mode 100644 MQWeb/src/AuthenticationInformationController.cpp create mode 100644 MQWeb/src/AuthenticationInformationMapper.cpp create mode 100644 MQWeb/src/QueueStatusController.cpp create mode 100644 MQWeb/src/QueueStatusMapper.cpp diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index a17e1d8..45e205c 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -2292,6 +2292,23 @@ Dictionary serviceDictionary = Dictionary() (MQCA_SERVICE_STOP_COMMAND, "StopCommand") ; +Dictionary authenticationInformationDictionary = Dictionary() + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) + (MQCA_AUTH_INFO_CONN_NAME, "AuthInfoConnName") + (MQCA_AUTH_INFO_DESC, "AuthInfoDesc") + (MQCA_AUTH_INFO_NAME, "AuthInfoName") + (MQIA_AUTH_INFO_TYPE, "AuthInfoType", DisplayMapInitializer + (MQAIT_ALL, "All") + (MQAIT_CRL_LDAP, "CRL LDAP") + (MQAIT_OCSP, "OCSP") + ) + (MQCA_LDAP_PASSWORD, "LDAPPassword") + (MQCA_LDAP_USER_NAME, "LDAPUserName") + (MQCA_AUTH_INFO_OCSP_URL, "OCSPResponderURL") + (MQIA_QSG_DISP) +; + class MQDictionary : public Poco::Util::Application { public: @@ -2404,6 +2421,7 @@ int main(const std::vector& args) store(session, ++oid, "Namelist", namelistDictionary); store(session, ++oid, "Process", processDictionary); store(session, ++oid, "Service", serviceDictionary); + store(session, ++oid, "AuthenticationInformation", authenticationInformationDictionary); return Application::EXIT_OK; } diff --git a/MQWeb/include/MQ/Web/AuthenticationInformationController.h b/MQWeb/include/MQ/Web/AuthenticationInformationController.h new file mode 100644 index 0000000..56ac277 --- /dev/null +++ b/MQWeb/include/MQ/Web/AuthenticationInformationController.h @@ -0,0 +1,79 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_AuthenticationInformationController_h +#define _MQWeb_AuthenticationInformationController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class AuthenticationInformationController : public MQController + /// Controller that shows the status of queues +{ +public: + AuthenticationInformationController(); + /// Constructor + + virtual ~AuthenticationInformationController(); + /// Destructor + + virtual const std::map& getActions() const; + /// Returns all available actions + + void inquire(); + /// Action inquire. Inquire authentication information objects and returns all data in JSON format. + /// URL's: + /// authinfo/inquire/ + /// authinfo/inquire// + /// authinfo/inquire/?authInfoName=MQWEB* + /// + /// Query Parameters: + /// authInfoName: Name of the authentication information object (* is default). + /// excludeSystem: when 'true', queues starting with 'SYSTEM.' are excluded. + /// + /// The authInfoName query parameter is ignored when a authInfoName is passed in the URI path. + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// authinfos : An array with all authentication information objects. This is always an array. + /// When an MQ error occurs there will be no authinfos property. + /// error: An object describing the MQ error (only returned on error). + +private: +}; + + +inline const Controller::ActionMap& AuthenticationInformationController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&AuthenticationInformationController::inquire)) + ; + return actions; +} + + +} } // Namespace MQ::Web + +#endif // _MQWeb_AuthenticationInformationController_h diff --git a/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h b/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h new file mode 100644 index 0000000..93415e0 --- /dev/null +++ b/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQWeb_AuthenticationInformationMapper_H +#define _MQWeb_AuthenticationInformationMapper_H + +#include "MQ/Web/MQMapper.h" + +namespace MQ { +namespace Web { + +class AuthenticationInformationMapper : public MQMapper + /// Maps queue object to Websphere MQ +{ +public: + + AuthenticationInformationMapper(CommandServer& commandServer); + /// Constructor + + virtual ~AuthenticationInformationMapper(); + /// Destructor + + void change(const Poco::JSON::Object::Ptr&obj); + /// Implements the change authentication information command. Not implemented yet. + + void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the create authentication information command. Not implemented yet. + + void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the copy authentication information command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + /// Implements the inquire authentication information command. + +private: + + AuthenticationInformationMapper(const AuthenticationInformationMapper&); +}; + + +}} // Namespace MQ::Web + +#endif // _MQWeb_AuthenticationInformationMapper_H diff --git a/MQWeb/include/MQ/Web/QueueStatusController.h b/MQWeb/include/MQ/Web/QueueStatusController.h new file mode 100644 index 0000000..e6b1eb8 --- /dev/null +++ b/MQWeb/include/MQ/Web/QueueStatusController.h @@ -0,0 +1,82 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_QueueStatusController_h +#define _MQWeb_QueueStatusController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class QueueStatusController : public MQController + /// Controller that shows the status of queues +{ +public: + QueueStatusController(); + /// Constructor + + virtual ~QueueStatusController(); + /// Destructor + + virtual const std::map& getActions() const; + /// Returns all available actions + + void inquire(); + /// Action inquire. Inquire status and returns all data in JSON format. + /// URL's: + /// qstatus/inquire/ + /// qstatus/inquire// + /// qstatus/inquire/?queueName=MQWEB*&openType=Input + /// + /// Query Parameters: + /// queueName: Name of the queue (* is default). + /// openType: All, Input or Output (default is All) + /// statusType: Queue Status or Handle (default is Queue Status) + /// excludeSystem: when 'true', queues starting with 'SYSTEM.' are excluded. + /// excludeTemp: when 'true', temporary queues are excluded. + /// + /// The queueName query parameter is ignored when a queueName is passed in the URI path. + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// statuses : An array with all statuses. This is always an array. + /// When an MQ error occurs there will be no statuses property. + /// error: An object describing the MQ error (only returned on error). + +private: +}; + + +inline const Controller::ActionMap& QueueStatusController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&QueueStatusController::inquire)) + ; + return actions; +} + + +} } // Namespace MQ::Web + +#endif // _MQWeb_QueueStatusController_h diff --git a/MQWeb/src/AuthenticationInformationController.cpp b/MQWeb/src/AuthenticationInformationController.cpp new file mode 100644 index 0000000..a5dd4ba --- /dev/null +++ b/MQWeb/src/AuthenticationInformationController.cpp @@ -0,0 +1,73 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/AuthenticationInformationController.h" +#include "MQ/Web/AuthenticationInformationMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + + +AuthenticationInformationController::AuthenticationInformationController() : MQController() +{ +} + + +AuthenticationInformationController::~AuthenticationInformationController() +{ +} + + +void AuthenticationInformationController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a authentication information name and will result in inquiring + // only that queue and ignores all query parameters. + if ( parameters.size() > 1 ) + { + filter->set("authInfoName", parameters[1]); + } + else + { + // Handle query parameters + std::string authInfoNameField = form().get("authInfoName", "*"); + if ( authInfoNameField.empty() ) + { + authInfoNameField = "*"; + } + filter->set("authInfoName", authInfoNameField); + + filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + } + + AuthenticationInformationMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("authinfos", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/AuthenticationInformationMapper.cpp b/MQWeb/src/AuthenticationInformationMapper.cpp new file mode 100644 index 0000000..c69f45f --- /dev/null +++ b/MQWeb/src/AuthenticationInformationMapper.cpp @@ -0,0 +1,94 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/AuthenticationInformationMapper.h" +#include "MQ/Web/Dictionary.h" +#include "MQ/MQException.h" + +namespace MQ { +namespace Web { + +AuthenticationInformationMapper::AuthenticationInformationMapper(CommandServer& commandServer) : MQMapper(commandServer, "AuthenticationInformation") +{ +} + +AuthenticationInformationMapper::~AuthenticationInformationMapper() +{ +} + + +void AuthenticationInformationMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthenticationInformationMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthenticationInformationMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr jsonAuthInfos = new Poco::JSON::Array(); + + PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_Q); + command->addParameter(MQCA_AUTH_INFO_NAME, filter->optValue("authInfoName", "*")); + + PCF::Vector commandResponse; + _commandServer.sendCommand(command, commandResponse); + + bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeTemp = filter->optValue("excludeTemp", false); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + std::string qName = (*it)->getParameterString(MQCA_AUTH_INFO_NAME); + if ( excludeSystem + && qName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } + + Poco::JSON::Object::Ptr jsonAuthInfo = new Poco::JSON::Object(); + jsonAuthInfos->add(jsonAuthInfo); + + dictionary()->mapToJSON(**it, jsonAuthInfo); + } + + return jsonAuthInfos; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index a5cb81e..ca49c9a 100644 --- a/MQWeb/src/ControllerRequestHandler.cpp +++ b/MQWeb/src/ControllerRequestHandler.cpp @@ -20,6 +20,7 @@ */ #include "MQ/Web/ControllerRequestHandler.h" #include "MQ/Web/WebController.h" +#include "MQ/Web/AuthenticationInformationController.h" #include "MQ/Web/ChannelController.h" #include "MQ/Web/ChannelStatusController.h" #include "MQ/Web/ClusterQueueManagerController.h" @@ -32,6 +33,7 @@ #include "MQ/Web/QueueController.h" #include "MQ/Web/QueueManagerController.h" #include "MQ/Web/QueueManagerStatusController.h" +#include "MQ/Web/QueueStatusController.h" #include "MQ/Web/ServiceController.h" #include "Poco/URI.h" @@ -120,6 +122,8 @@ void ControllerRequestHandler::registerControllers() _controllerFactory.registerClass("nl"); _controllerFactory.registerClass("process"); _controllerFactory.registerClass("service"); + _controllerFactory.registerClass("qstatus"); + _controllerFactory.registerClass("authinfo"); } diff --git a/MQWeb/src/QueueStatusController.cpp b/MQWeb/src/QueueStatusController.cpp new file mode 100644 index 0000000..b44b2f9 --- /dev/null +++ b/MQWeb/src/QueueStatusController.cpp @@ -0,0 +1,75 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/QueueStatusController.h" +#include "MQ/Web/QueueStatusMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + + +QueueStatusController::QueueStatusController() : MQController() +{ +} + + +QueueStatusController::~QueueStatusController() +{ +} + + +void QueueStatusController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a queuename and will result in inquiring + // only that queue + if ( parameters.size() > 1 ) + { + filter->set("queueName", parameters[1]); + } + else + { + if ( form().has("queueName") ) + { + std::string nameField = form().get("queueName"); + if ( nameField.empty() ) nameField = "*"; + filter->set("queueName", nameField); + } + filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + filter->set("excludeTemp", form().get("excludeTemp", "false").compare("true") == 0); + } + + if ( form().has("statusType") ) filter->set("statusType", form().get("statusType")); + if ( form().has("openType") ) filter->set("openType", form().get("openType")); + + QueueStatusMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("statuses", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/QueueStatusMapper.cpp b/MQWeb/src/QueueStatusMapper.cpp new file mode 100644 index 0000000..e0a39f2 --- /dev/null +++ b/MQWeb/src/QueueStatusMapper.cpp @@ -0,0 +1,120 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/QueueStatusMapper.h" +#include "MQ/Web/Dictionary.h" +#include "MQ/MQException.h" + +namespace MQ { +namespace Web { + +QueueStatusMapper::QueueStatusMapper(CommandServer& commandServer) : MQMapper(commandServer, "QueueStatus") +{ +} + +QueueStatusMapper::~QueueStatusMapper() +{ +} + + +void QueueStatusMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void QueueStatusMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void QueueStatusMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr QueueStatusMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); + + PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_Q_STATUS); + command->addParameter(MQCA_Q_NAME, filter->optValue("queueName", "*")); + + if ( filter->has("openType") ) + { + std::string type = filter->optValue("openType", "All"); + MQLONG typeValue = dictionary()->getDisplayId(MQIACF_OPEN_TYPE, type); + poco_assert_dbg(typeValue != -1); + if ( typeValue != MQQSOT_ALL ) + { + command->addParameter(MQIACF_OPEN_TYPE, typeValue); + } + } + + if ( filter->has("statusType") ) + { + std::string type = filter->optValue("statusType", "Queue Status"); + MQLONG typeValue = dictionary()->getDisplayId(MQIACF_STATUS_TYPE, type); + poco_assert_dbg(typeValue != -1); + command->addParameter(MQIACF_STATUS_TYPE, typeValue); + } + + PCF::Vector commandResponse; + _commandServer.sendCommand(command, commandResponse); + + bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeTemp = filter->optValue("excludeTemp", false); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + std::string qName = (*it)->getParameterString(MQCA_Q_NAME); + if ( excludeSystem + && qName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } + + if ( excludeTemp + && (*it)->hasParameter(MQIA_DEFINITION_TYPE) + && (*it)->getParameterNum(MQIA_DEFINITION_TYPE) == MQQDT_TEMPORARY_DYNAMIC ) + { + continue; + } + + Poco::JSON::Object::Ptr jsonStatus = new Poco::JSON::Object(); + json->add(jsonStatus); + + dictionary()->mapToJSON(**it, jsonStatus); + } + + return json; +} + +}} // Namespace MQ::Web From c2d6e27b274cc4d1c7fd31e11ca58f0e4b3ba9f0 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 6 Aug 2014 16:05:36 +0200 Subject: [PATCH 014/143] Working on Queue Status and Authenthication Information --- MQDictionary/src/Application.cpp | 18 +++ .../Web/AuthenticationInformationController.h | 79 ++++++++++++ .../MQ/Web/AuthenticationInformationMapper.h | 60 +++++++++ MQWeb/include/MQ/Web/QueueStatusController.h | 82 ++++++++++++ MQWeb/include/MQ/Web/QueueStatusMapper.h | 60 +++++++++ .../AuthenticationInformationController.cpp | 73 +++++++++++ MQWeb/src/AuthenticationInformationMapper.cpp | 94 ++++++++++++++ MQWeb/src/ControllerRequestHandler.cpp | 4 + MQWeb/src/QueueStatusController.cpp | 75 +++++++++++ MQWeb/src/QueueStatusMapper.cpp | 120 ++++++++++++++++++ 10 files changed, 665 insertions(+) create mode 100644 MQWeb/include/MQ/Web/AuthenticationInformationController.h create mode 100644 MQWeb/include/MQ/Web/AuthenticationInformationMapper.h create mode 100644 MQWeb/include/MQ/Web/QueueStatusController.h create mode 100644 MQWeb/include/MQ/Web/QueueStatusMapper.h create mode 100644 MQWeb/src/AuthenticationInformationController.cpp create mode 100644 MQWeb/src/AuthenticationInformationMapper.cpp create mode 100644 MQWeb/src/QueueStatusController.cpp create mode 100644 MQWeb/src/QueueStatusMapper.cpp diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index a17e1d8..45e205c 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -2292,6 +2292,23 @@ Dictionary serviceDictionary = Dictionary() (MQCA_SERVICE_STOP_COMMAND, "StopCommand") ; +Dictionary authenticationInformationDictionary = Dictionary() + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) + (MQCA_AUTH_INFO_CONN_NAME, "AuthInfoConnName") + (MQCA_AUTH_INFO_DESC, "AuthInfoDesc") + (MQCA_AUTH_INFO_NAME, "AuthInfoName") + (MQIA_AUTH_INFO_TYPE, "AuthInfoType", DisplayMapInitializer + (MQAIT_ALL, "All") + (MQAIT_CRL_LDAP, "CRL LDAP") + (MQAIT_OCSP, "OCSP") + ) + (MQCA_LDAP_PASSWORD, "LDAPPassword") + (MQCA_LDAP_USER_NAME, "LDAPUserName") + (MQCA_AUTH_INFO_OCSP_URL, "OCSPResponderURL") + (MQIA_QSG_DISP) +; + class MQDictionary : public Poco::Util::Application { public: @@ -2404,6 +2421,7 @@ int main(const std::vector& args) store(session, ++oid, "Namelist", namelistDictionary); store(session, ++oid, "Process", processDictionary); store(session, ++oid, "Service", serviceDictionary); + store(session, ++oid, "AuthenticationInformation", authenticationInformationDictionary); return Application::EXIT_OK; } diff --git a/MQWeb/include/MQ/Web/AuthenticationInformationController.h b/MQWeb/include/MQ/Web/AuthenticationInformationController.h new file mode 100644 index 0000000..56ac277 --- /dev/null +++ b/MQWeb/include/MQ/Web/AuthenticationInformationController.h @@ -0,0 +1,79 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_AuthenticationInformationController_h +#define _MQWeb_AuthenticationInformationController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class AuthenticationInformationController : public MQController + /// Controller that shows the status of queues +{ +public: + AuthenticationInformationController(); + /// Constructor + + virtual ~AuthenticationInformationController(); + /// Destructor + + virtual const std::map& getActions() const; + /// Returns all available actions + + void inquire(); + /// Action inquire. Inquire authentication information objects and returns all data in JSON format. + /// URL's: + /// authinfo/inquire/ + /// authinfo/inquire// + /// authinfo/inquire/?authInfoName=MQWEB* + /// + /// Query Parameters: + /// authInfoName: Name of the authentication information object (* is default). + /// excludeSystem: when 'true', queues starting with 'SYSTEM.' are excluded. + /// + /// The authInfoName query parameter is ignored when a authInfoName is passed in the URI path. + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// authinfos : An array with all authentication information objects. This is always an array. + /// When an MQ error occurs there will be no authinfos property. + /// error: An object describing the MQ error (only returned on error). + +private: +}; + + +inline const Controller::ActionMap& AuthenticationInformationController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&AuthenticationInformationController::inquire)) + ; + return actions; +} + + +} } // Namespace MQ::Web + +#endif // _MQWeb_AuthenticationInformationController_h diff --git a/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h b/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h new file mode 100644 index 0000000..93415e0 --- /dev/null +++ b/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQWeb_AuthenticationInformationMapper_H +#define _MQWeb_AuthenticationInformationMapper_H + +#include "MQ/Web/MQMapper.h" + +namespace MQ { +namespace Web { + +class AuthenticationInformationMapper : public MQMapper + /// Maps queue object to Websphere MQ +{ +public: + + AuthenticationInformationMapper(CommandServer& commandServer); + /// Constructor + + virtual ~AuthenticationInformationMapper(); + /// Destructor + + void change(const Poco::JSON::Object::Ptr&obj); + /// Implements the change authentication information command. Not implemented yet. + + void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the create authentication information command. Not implemented yet. + + void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the copy authentication information command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + /// Implements the inquire authentication information command. + +private: + + AuthenticationInformationMapper(const AuthenticationInformationMapper&); +}; + + +}} // Namespace MQ::Web + +#endif // _MQWeb_AuthenticationInformationMapper_H diff --git a/MQWeb/include/MQ/Web/QueueStatusController.h b/MQWeb/include/MQ/Web/QueueStatusController.h new file mode 100644 index 0000000..e6b1eb8 --- /dev/null +++ b/MQWeb/include/MQ/Web/QueueStatusController.h @@ -0,0 +1,82 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_QueueStatusController_h +#define _MQWeb_QueueStatusController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class QueueStatusController : public MQController + /// Controller that shows the status of queues +{ +public: + QueueStatusController(); + /// Constructor + + virtual ~QueueStatusController(); + /// Destructor + + virtual const std::map& getActions() const; + /// Returns all available actions + + void inquire(); + /// Action inquire. Inquire status and returns all data in JSON format. + /// URL's: + /// qstatus/inquire/ + /// qstatus/inquire// + /// qstatus/inquire/?queueName=MQWEB*&openType=Input + /// + /// Query Parameters: + /// queueName: Name of the queue (* is default). + /// openType: All, Input or Output (default is All) + /// statusType: Queue Status or Handle (default is Queue Status) + /// excludeSystem: when 'true', queues starting with 'SYSTEM.' are excluded. + /// excludeTemp: when 'true', temporary queues are excluded. + /// + /// The queueName query parameter is ignored when a queueName is passed in the URI path. + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// statuses : An array with all statuses. This is always an array. + /// When an MQ error occurs there will be no statuses property. + /// error: An object describing the MQ error (only returned on error). + +private: +}; + + +inline const Controller::ActionMap& QueueStatusController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&QueueStatusController::inquire)) + ; + return actions; +} + + +} } // Namespace MQ::Web + +#endif // _MQWeb_QueueStatusController_h diff --git a/MQWeb/include/MQ/Web/QueueStatusMapper.h b/MQWeb/include/MQ/Web/QueueStatusMapper.h new file mode 100644 index 0000000..2785ddc --- /dev/null +++ b/MQWeb/include/MQ/Web/QueueStatusMapper.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQWeb_QueueStatusMapper_H +#define _MQWeb_QueueStatusMapper_H + +#include "MQ/Web/MQMapper.h" + +namespace MQ { +namespace Web { + +class QueueStatusMapper : public MQMapper + /// Maps queue status object to Websphere MQ +{ +public: + + QueueStatusMapper(CommandServer& commandServer); + /// Constructor + + virtual ~QueueStatusMapper(); + /// Destructor + + void change(const Poco::JSON::Object::Ptr&obj); + /// Not available. + + void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Not available. + + void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Not available. + + Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + /// Implements the inquire queue status command. + +private: + + QueueStatusMapper(const QueueStatusMapper&); +}; + + +}} // Namespace MQ::Web + +#endif // _MQWeb_QueueStatusMapper_H diff --git a/MQWeb/src/AuthenticationInformationController.cpp b/MQWeb/src/AuthenticationInformationController.cpp new file mode 100644 index 0000000..a5dd4ba --- /dev/null +++ b/MQWeb/src/AuthenticationInformationController.cpp @@ -0,0 +1,73 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/AuthenticationInformationController.h" +#include "MQ/Web/AuthenticationInformationMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + + +AuthenticationInformationController::AuthenticationInformationController() : MQController() +{ +} + + +AuthenticationInformationController::~AuthenticationInformationController() +{ +} + + +void AuthenticationInformationController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a authentication information name and will result in inquiring + // only that queue and ignores all query parameters. + if ( parameters.size() > 1 ) + { + filter->set("authInfoName", parameters[1]); + } + else + { + // Handle query parameters + std::string authInfoNameField = form().get("authInfoName", "*"); + if ( authInfoNameField.empty() ) + { + authInfoNameField = "*"; + } + filter->set("authInfoName", authInfoNameField); + + filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + } + + AuthenticationInformationMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("authinfos", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/AuthenticationInformationMapper.cpp b/MQWeb/src/AuthenticationInformationMapper.cpp new file mode 100644 index 0000000..c69f45f --- /dev/null +++ b/MQWeb/src/AuthenticationInformationMapper.cpp @@ -0,0 +1,94 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/AuthenticationInformationMapper.h" +#include "MQ/Web/Dictionary.h" +#include "MQ/MQException.h" + +namespace MQ { +namespace Web { + +AuthenticationInformationMapper::AuthenticationInformationMapper(CommandServer& commandServer) : MQMapper(commandServer, "AuthenticationInformation") +{ +} + +AuthenticationInformationMapper::~AuthenticationInformationMapper() +{ +} + + +void AuthenticationInformationMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthenticationInformationMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthenticationInformationMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr jsonAuthInfos = new Poco::JSON::Array(); + + PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_Q); + command->addParameter(MQCA_AUTH_INFO_NAME, filter->optValue("authInfoName", "*")); + + PCF::Vector commandResponse; + _commandServer.sendCommand(command, commandResponse); + + bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeTemp = filter->optValue("excludeTemp", false); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + std::string qName = (*it)->getParameterString(MQCA_AUTH_INFO_NAME); + if ( excludeSystem + && qName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } + + Poco::JSON::Object::Ptr jsonAuthInfo = new Poco::JSON::Object(); + jsonAuthInfos->add(jsonAuthInfo); + + dictionary()->mapToJSON(**it, jsonAuthInfo); + } + + return jsonAuthInfos; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index a5cb81e..ca49c9a 100644 --- a/MQWeb/src/ControllerRequestHandler.cpp +++ b/MQWeb/src/ControllerRequestHandler.cpp @@ -20,6 +20,7 @@ */ #include "MQ/Web/ControllerRequestHandler.h" #include "MQ/Web/WebController.h" +#include "MQ/Web/AuthenticationInformationController.h" #include "MQ/Web/ChannelController.h" #include "MQ/Web/ChannelStatusController.h" #include "MQ/Web/ClusterQueueManagerController.h" @@ -32,6 +33,7 @@ #include "MQ/Web/QueueController.h" #include "MQ/Web/QueueManagerController.h" #include "MQ/Web/QueueManagerStatusController.h" +#include "MQ/Web/QueueStatusController.h" #include "MQ/Web/ServiceController.h" #include "Poco/URI.h" @@ -120,6 +122,8 @@ void ControllerRequestHandler::registerControllers() _controllerFactory.registerClass("nl"); _controllerFactory.registerClass("process"); _controllerFactory.registerClass("service"); + _controllerFactory.registerClass("qstatus"); + _controllerFactory.registerClass("authinfo"); } diff --git a/MQWeb/src/QueueStatusController.cpp b/MQWeb/src/QueueStatusController.cpp new file mode 100644 index 0000000..b44b2f9 --- /dev/null +++ b/MQWeb/src/QueueStatusController.cpp @@ -0,0 +1,75 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/QueueStatusController.h" +#include "MQ/Web/QueueStatusMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + + +QueueStatusController::QueueStatusController() : MQController() +{ +} + + +QueueStatusController::~QueueStatusController() +{ +} + + +void QueueStatusController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a queuename and will result in inquiring + // only that queue + if ( parameters.size() > 1 ) + { + filter->set("queueName", parameters[1]); + } + else + { + if ( form().has("queueName") ) + { + std::string nameField = form().get("queueName"); + if ( nameField.empty() ) nameField = "*"; + filter->set("queueName", nameField); + } + filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + filter->set("excludeTemp", form().get("excludeTemp", "false").compare("true") == 0); + } + + if ( form().has("statusType") ) filter->set("statusType", form().get("statusType")); + if ( form().has("openType") ) filter->set("openType", form().get("openType")); + + QueueStatusMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("statuses", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/QueueStatusMapper.cpp b/MQWeb/src/QueueStatusMapper.cpp new file mode 100644 index 0000000..e0a39f2 --- /dev/null +++ b/MQWeb/src/QueueStatusMapper.cpp @@ -0,0 +1,120 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/QueueStatusMapper.h" +#include "MQ/Web/Dictionary.h" +#include "MQ/MQException.h" + +namespace MQ { +namespace Web { + +QueueStatusMapper::QueueStatusMapper(CommandServer& commandServer) : MQMapper(commandServer, "QueueStatus") +{ +} + +QueueStatusMapper::~QueueStatusMapper() +{ +} + + +void QueueStatusMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void QueueStatusMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void QueueStatusMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr QueueStatusMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); + + PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_Q_STATUS); + command->addParameter(MQCA_Q_NAME, filter->optValue("queueName", "*")); + + if ( filter->has("openType") ) + { + std::string type = filter->optValue("openType", "All"); + MQLONG typeValue = dictionary()->getDisplayId(MQIACF_OPEN_TYPE, type); + poco_assert_dbg(typeValue != -1); + if ( typeValue != MQQSOT_ALL ) + { + command->addParameter(MQIACF_OPEN_TYPE, typeValue); + } + } + + if ( filter->has("statusType") ) + { + std::string type = filter->optValue("statusType", "Queue Status"); + MQLONG typeValue = dictionary()->getDisplayId(MQIACF_STATUS_TYPE, type); + poco_assert_dbg(typeValue != -1); + command->addParameter(MQIACF_STATUS_TYPE, typeValue); + } + + PCF::Vector commandResponse; + _commandServer.sendCommand(command, commandResponse); + + bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeTemp = filter->optValue("excludeTemp", false); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + std::string qName = (*it)->getParameterString(MQCA_Q_NAME); + if ( excludeSystem + && qName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } + + if ( excludeTemp + && (*it)->hasParameter(MQIA_DEFINITION_TYPE) + && (*it)->getParameterNum(MQIA_DEFINITION_TYPE) == MQQDT_TEMPORARY_DYNAMIC ) + { + continue; + } + + Poco::JSON::Object::Ptr jsonStatus = new Poco::JSON::Object(); + json->add(jsonStatus); + + dictionary()->mapToJSON(**it, jsonStatus); + } + + return json; +} + +}} // Namespace MQ::Web From f12b099dd5c2e7069bc0964db3b7d8b71115fda2 Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 7 Aug 2014 22:13:37 +0200 Subject: [PATCH 015/143] Use correct command --- MQWeb/src/AuthenticationInformationMapper.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MQWeb/src/AuthenticationInformationMapper.cpp b/MQWeb/src/AuthenticationInformationMapper.cpp index c69f45f..2b093c2 100644 --- a/MQWeb/src/AuthenticationInformationMapper.cpp +++ b/MQWeb/src/AuthenticationInformationMapper.cpp @@ -58,14 +58,13 @@ Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire(const Poco::JSON Poco::JSON::Array::Ptr jsonAuthInfos = new Poco::JSON::Array(); - PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_Q); + PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_AUTH_INFO); command->addParameter(MQCA_AUTH_INFO_NAME, filter->optValue("authInfoName", "*")); PCF::Vector commandResponse; _commandServer.sendCommand(command, commandResponse); bool excludeSystem = filter->optValue("excludeSystem", false); - bool excludeTemp = filter->optValue("excludeTemp", false); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { From cca442c8271a143221e369fd463324e4ffe89a5a Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 7 Aug 2014 22:14:15 +0200 Subject: [PATCH 016/143] Add AuthorityRecord --- MQDictionary/src/Application.cpp | 62 +++++++- .../MQ/Web/AuthorityRecordController.h | 79 ++++++++++ MQWeb/include/MQ/Web/AuthorityRecordMapper.h | 60 ++++++++ MQWeb/src/AuthorityRecordController.cpp | 80 ++++++++++ MQWeb/src/AuthorityRecordMapper.cpp | 142 ++++++++++++++++++ MQWeb/src/ControllerRequestHandler.cpp | 2 + 6 files changed, 424 insertions(+), 1 deletion(-) create mode 100644 MQWeb/include/MQ/Web/AuthorityRecordController.h create mode 100644 MQWeb/include/MQ/Web/AuthorityRecordMapper.h create mode 100644 MQWeb/src/AuthorityRecordController.cpp create mode 100644 MQWeb/src/AuthorityRecordMapper.cpp diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 45e205c..886e94c 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -7,6 +7,7 @@ #include #include +#include using namespace MQ::Web; using namespace Poco::Data::Keywords; @@ -1645,6 +1646,7 @@ Dictionary eventDictionary = Dictionary() (MQIA_MSG_DEQ_COUNT, "MsgDeqCount") (MQCACF_OBJECT_Q_MGR_NAME, "ObjectQMgrName") (MQIACF_OBJECT_TYPE, "ObjectType", DisplayMapInitializer + (MQOT_ALL, "All") (MQOT_CHANNEL, "Channel") (MQOT_CHLAUTH, "Channel Authentication Record") (MQOT_NAMELIST, "Namelist") @@ -1658,6 +1660,23 @@ Dictionary eventDictionary = Dictionary() (MQOT_TOPIC, "Topic") (MQOT_COMM_INFO, "Communication Information") (MQOT_LISTENER, "Listener") + (MQOT_CLNTCONN_CHANNEL, "Client-connection Channel") + (MQOT_REMOTE_Q_MGR_NAME, "Remote Queuemanager") + (MQOT_SERVICE, "Service") + (MQOT_ALIAS_Q, "Alias Queue") + (MQOT_MODEL_Q, "Model Queue") + (MQOT_LOCAL_Q, "Local Queue") + (MQOT_REMOTE_Q, "Remote Queue") + (MQOT_SENDER_CHANNEL, "Sender Channel") + (MQOT_SERVER_CHANNEL, "Server Channel") + (MQOT_REQUESTER_CHANNEL, "Requester Channel") + (MQOT_RECEIVER_CHANNEL, "Receiver Channel") + (MQOT_CURRENT_CHANNEL, "Current Channel") + (MQOT_SAVED_CHANNEL, "Saved Channel") + (MQOT_SVRCONN_CHANNEL, "Server-connection Channel") + (MQOT_CLNTCONN_CHANNEL, "Client-connection Channel") + (MQOT_SHORT_CHANNEL, "Short Channel") + (MQOT_PROT_POLICY, "Protection Policy") ) (MQIACF_OPEN_OPTIONS, "OpenOptions") (MQCA_PROCESS_NAME, "ProcessName") @@ -2309,6 +2328,47 @@ Dictionary authenticationInformationDictionary = Dictionary() (MQIA_QSG_DISP) ; +Dictionary authorityRecordDictionary = Dictionary() + (MQIACF_AUTHORIZATION_LIST, "AuthorizationList", DisplayMapInitializer + (MQAUTH_NONE, "None") + (MQAUTH_ALT_USER_AUTHORITY, "Alt User Authority") + (MQAUTH_BROWSE, "Browse") + (MQAUTH_CHANGE, "Change") + (MQAUTH_CLEAR, "Clear") + (MQAUTH_CONNECT, "Connect") + (MQAUTH_CREATE, "Create") + (MQAUTH_DELETE, "Delete") + (MQAUTH_DISPLAY, "Display") + (MQAUTH_INPUT, "Input") + (MQAUTH_INQUIRE, "Inquire") + (MQAUTH_OUTPUT, "Output") + (MQAUTH_PASS_ALL_CONTEXT, "Pass All Context") + (MQAUTH_PASS_IDENTITY_CONTEXT, "Pass Identity Context") + (MQAUTH_SET, "Set") + (MQAUTH_SET_ALL_CONTEXT, "Set All Context") + (MQAUTH_SET_IDENTITY_CONTEXT, "Set Identity Context") + (MQAUTH_CONTROL, "Control") + (MQAUTH_CONTROL_EXTENDED, "Control Extended") + (MQAUTH_PUBLISH, "Publish") + (MQAUTH_SUBSCRIBE, "Subscribe") + (MQAUTH_RESUME, "Resume") + (MQAUTH_SYSTEM, "System") + (MQAUTH_ALL, "All") + (MQAUTH_ALL_ADMIN, "All Admin") + (MQAUTH_ALL_MQI, "All MQI") + ) + (MQCACF_ENTITY_NAME, "EntityName") + (MQIACF_ENTITY_TYPE, "EntityType", DisplayMapInitializer + (MQZAET_GROUP, "Group") + (MQZAET_PRINCIPAL, "Principal") + (MQZAET_UNKNOWN, "Unknown") + ) + (MQIACF_OBJECT_TYPE) + (MQIACF_AUTH_OPTIONS, "Options") + (MQCACF_AUTH_PROFILE_NAME, "ProfileName") + (MQCA_Q_MGR_NAME, "QMgrName") +; + class MQDictionary : public Poco::Util::Application { public: @@ -2422,7 +2482,7 @@ int main(const std::vector& args) store(session, ++oid, "Process", processDictionary); store(session, ++oid, "Service", serviceDictionary); store(session, ++oid, "AuthenticationInformation", authenticationInformationDictionary); - + store(session, ++oid, "AuthorityRecord", authorityRecordDictionary); return Application::EXIT_OK; } diff --git a/MQWeb/include/MQ/Web/AuthorityRecordController.h b/MQWeb/include/MQ/Web/AuthorityRecordController.h new file mode 100644 index 0000000..d082923 --- /dev/null +++ b/MQWeb/include/MQ/Web/AuthorityRecordController.h @@ -0,0 +1,79 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_AuthorityRecordController_h +#define _MQWeb_AuthorityRecordController_h + +#include "MQ/Web/MQController.h" +#include "MQ/Web/MapInitializer.h" + +namespace MQ { +namespace Web { + +class AuthorityRecordController : public MQController + /// Controller that shows the status of queues +{ +public: + AuthorityRecordController(); + /// Constructor + + virtual ~AuthorityRecordController(); + /// Destructor + + virtual const std::map& getActions() const; + /// Returns all available actions + + void inquire(); + /// Action inquire. Inquire authentication information objects and returns all data in JSON format. + /// URL's: + /// authinfo/inquire/ + /// authinfo/inquire// + /// authinfo/inquire/?authInfoName=MQWEB* + /// + /// Query Parameters: + /// authInfoName: Name of the authentication information object (* is default). + /// excludeSystem: when 'true', queues starting with 'SYSTEM.' are excluded. + /// + /// The authInfoName query parameter is ignored when a authInfoName is passed in the URI path. + /// + /// The returned JSON object can contain following properties: + /// mqweb : An object with information about the MQWeb application and request. + /// authinfos : An array with all authentication information objects. This is always an array. + /// When an MQ error occurs there will be no authinfos property. + /// error: An object describing the MQ error (only returned on error). + +private: +}; + + +inline const Controller::ActionMap& AuthorityRecordController::getActions() const +{ + static Controller::ActionMap actions + = MapInitializer + ("inquire", static_cast(&AuthorityRecordController::inquire)) + ; + return actions; +} + + +} } // Namespace MQ::Web + +#endif // _MQWeb_AuthorityRecordController_h diff --git a/MQWeb/include/MQ/Web/AuthorityRecordMapper.h b/MQWeb/include/MQ/Web/AuthorityRecordMapper.h new file mode 100644 index 0000000..81e54da --- /dev/null +++ b/MQWeb/include/MQ/Web/AuthorityRecordMapper.h @@ -0,0 +1,60 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQWeb_AuthorityRecordMapper_H +#define _MQWeb_AuthorityRecordMapper_H + +#include "MQ/Web/MQMapper.h" + +namespace MQ { +namespace Web { + +class AuthorityRecordMapper : public MQMapper + /// Maps queue object to Websphere MQ +{ +public: + + AuthorityRecordMapper(CommandServer& commandServer); + /// Constructor + + virtual ~AuthorityRecordMapper(); + /// Destructor + + void change(const Poco::JSON::Object::Ptr&obj); + /// Implements the change authority records command. Not implemented yet. + + void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the create authority records command. Not implemented yet. + + void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + /// Implements the copy authority records command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + /// Implements the inquire authority records command. + +private: + + AuthorityRecordMapper(const AuthorityRecordMapper&); +}; + + +}} // Namespace MQ::Web + +#endif // _MQWeb_AuthorityRecordMapper_H diff --git a/MQWeb/src/AuthorityRecordController.cpp b/MQWeb/src/AuthorityRecordController.cpp new file mode 100644 index 0000000..663fedc --- /dev/null +++ b/MQWeb/src/AuthorityRecordController.cpp @@ -0,0 +1,80 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/AuthorityRecordController.h" +#include "MQ/Web/AuthorityRecordMapper.h" +#include "MQ/Web/JSONView.h" + +namespace MQ +{ +namespace Web +{ + + +AuthorityRecordController::AuthorityRecordController() : MQController() +{ +} + + +AuthorityRecordController::~AuthorityRecordController() +{ +} + + +void AuthorityRecordController::inquire() +{ + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a authentication information name and will result in inquiring + // only that queue and ignores all query parameters. + if ( parameters.size() > 1 ) + { + filter->set("profileName", parameters[1]); + } + else + { + // Handle query parameters + if ( form().has("profileName") ) filter->set("profileName", form().get("profileName")); + } + + Poco::JSON::Array::Ptr jsonOptions = new Poco::JSON::Array(); + filter->set("options", jsonOptions); + for(Poco::Net::NameValueCollection::ConstIterator itOptions = form().find("options"); + itOptions != form().end() && itOptions->first == "options"; + ++itOptions) + { + jsonOptions->add(itOptions->second); + } + + if ( form().has("objectType") ) filter->set("objectType", form().get("objectType")); + if ( form().has("entityName") ) filter->set("entityName", form().get("entityName")); + if ( form().has("entityType") ) filter->set("entityType", form().get("entityType")); + if ( form().has("serviceComponent") ) filter->set("serviceComponent", form().get("serviceComponent")); + + AuthorityRecordMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr json = mapper.inquire(filter); + set("authrecs", json); + setView(new JSONView()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/AuthorityRecordMapper.cpp b/MQWeb/src/AuthorityRecordMapper.cpp new file mode 100644 index 0000000..16085ab --- /dev/null +++ b/MQWeb/src/AuthorityRecordMapper.cpp @@ -0,0 +1,142 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or ? as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/AuthorityRecordMapper.h" + +namespace MQ { +namespace Web { + +AuthorityRecordMapper::AuthorityRecordMapper(CommandServer& commandServer) : MQMapper(commandServer, "AuthorityRecord") +{ +} + +AuthorityRecordMapper::~AuthorityRecordMapper() +{ +} + + +void AuthorityRecordMapper::change(const Poco::JSON::Object::Ptr&obj) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthorityRecordMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthorityRecordMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire(const Poco::JSON::Object::Ptr& filter) +{ + poco_assert_dbg(!filter.isNull()); + + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); + + PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_AUTH_RECS); + + if ( filter->has("profileName") ) command->addParameter(MQCACF_AUTH_PROFILE_NAME, filter->optValue("profileName", "*")); + + MQLONG options = 0; + Poco::JSON::Array::Ptr optionsValue = filter->getArray("options"); + if ( !optionsValue.isNull() ) + { + for(Poco::JSON::Array::ValueVec::const_iterator it = optionsValue->begin(); it != optionsValue->end(); ++it) + { + std::string value = *it; + if ( value.compare("Name All Matching") == 0 ) + { + options |= MQAUTHOPT_NAME_ALL_MATCHING; + } + else if ( value.compare("Name Explicit") == 0 ) + { + options |= MQAUTHOPT_NAME_EXPLICIT; + } + else if ( value.compare("Entity Explicit") == 0 ) + { + options |= MQAUTHOPT_ENTITY_EXPLICIT; + } + else if ( value.compare("Entity Set") == 0 ) + { + options |= MQAUTHOPT_ENTITY_SET; + } + else if ( value.compare("Name As Wildcard") == 0 ) + { + options |= MQAUTHOPT_NAME_AS_WILDCARD; + } + } + } + command->addParameter(MQIACF_AUTH_OPTIONS, options); + + std::string objectType = filter->optValue("objectType", "All"); + MQLONG objectTypeValue = dictionary()->getDisplayId(MQIACF_OBJECT_TYPE, objectType); + poco_assert_dbg(objectTypeValue != -1); + if ( objectTypeValue == - 1 ) + { + return json; + } + command->addParameter(MQIACF_OBJECT_TYPE, objectTypeValue); + + if ( filter->has("entityName") ) command->addParameter(MQCACF_ENTITY_NAME, filter->optValue("entityName", "")); + + if ( filter->has("entityType") ) + { + std::string entityType = filter->optValue("entityType", ""); + if ( !entityType.empty() ) + { + MQLONG entityTypeValue = dictionary()->getDisplayId(MQIACF_ENTITY_TYPE, entityType); + poco_assert_dbg(entityTypeValue != -1); + if ( entityTypeValue == - 1 ) + { + return json; + } + command->addParameter(MQIACF_ENTITY_TYPE, entityTypeValue); + } + } + + if ( filter->has("serviceComponent") ) command->addParameter(MQCACF_SERVICE_COMPONENT, filter->optValue("serviceComponent", "")); + + PCF::Vector commandResponse; + _commandServer.sendCommand(command, commandResponse); + + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) + { + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + Poco::JSON::Object::Ptr object = new Poco::JSON::Object(); + json->add(object); + + dictionary()->mapToJSON(**it, object); + } + + return json; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index ca49c9a..1c999fd 100644 --- a/MQWeb/src/ControllerRequestHandler.cpp +++ b/MQWeb/src/ControllerRequestHandler.cpp @@ -21,6 +21,7 @@ #include "MQ/Web/ControllerRequestHandler.h" #include "MQ/Web/WebController.h" #include "MQ/Web/AuthenticationInformationController.h" +#include "MQ/Web/AuthorityRecordController.h" #include "MQ/Web/ChannelController.h" #include "MQ/Web/ChannelStatusController.h" #include "MQ/Web/ClusterQueueManagerController.h" @@ -124,6 +125,7 @@ void ControllerRequestHandler::registerControllers() _controllerFactory.registerClass("service"); _controllerFactory.registerClass("qstatus"); _controllerFactory.registerClass("authinfo"); + _controllerFactory.registerClass("authrec"); } From b3c738e2ad5d929651a4defe3112fa6a3885ce61 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 8 Aug 2014 19:08:45 +0200 Subject: [PATCH 017/143] Support JSONP --- MQWeb/include/MQ/Web/Controller.h | 15 ++++++---- MQWeb/include/MQ/Web/JSONPView.h | 50 +++++++++++++++++++++++++++++++ MQWeb/src/Controller.cpp | 7 +++++ MQWeb/src/JSONPView.cpp | 45 ++++++++++++++++++++++++++++ MQWeb/src/MQController.cpp | 2 +- 5 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 MQWeb/include/MQ/Web/JSONPView.h create mode 100644 MQWeb/src/JSONPView.cpp diff --git a/MQWeb/include/MQ/Web/Controller.h b/MQWeb/include/MQ/Web/Controller.h index 168e27b..22fea53 100644 --- a/MQWeb/include/MQ/Web/Controller.h +++ b/MQWeb/include/MQ/Web/Controller.h @@ -68,7 +68,8 @@ class Controller : public Poco::Net::PartHandler /// Called before an action is executed. virtual void afterAction(); - /// Called after an action is executed. + /// Called after an action is executed. The default implementation renders + /// the associated view. When no view is set, a JSON view will be used virtual const ActionMap& getActions() const = 0; /// Returns all actions. @@ -97,6 +98,9 @@ class Controller : public Poco::Net::PartHandler Poco::Net::HTTPServerResponse& response(); /// Returns the HTTP response + void setJSONView(); + /// Checks for JSONP or JSON request and creates the corresponding view class + void setResponseStatus(Poco::Net::HTTPServerResponse::HTTPStatus status); /// Sets the HTTP response status. This will send the response to the client. @@ -151,11 +155,10 @@ class Controller : public Poco::Net::PartHandler inline void Controller::afterAction() { - //default: render the view if one is set - if ( !_view.isNull() ) - { - render(); - } + // When no view is set yet, we assume JSON + if ( _view.isNull() ) setJSONView(); + + render(); } diff --git a/MQWeb/include/MQ/Web/JSONPView.h b/MQWeb/include/MQ/Web/JSONPView.h new file mode 100644 index 0000000..f7975db --- /dev/null +++ b/MQWeb/include/MQ/Web/JSONPView.h @@ -0,0 +1,50 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#ifndef _MQWeb_JSONPView_H +#define _MQWeb_JSONPView_H + +#include "Poco/Net/HTTPServerResponse.h" +#include "MQ/Web/JSONView.h" + +namespace MQ { +namespace Web { + +class JSONPView : public JSONView + /// A special JSON view that implments the JSONP technique +{ +public: + JSONPView(const std::string& callback); + /// Constructor + + virtual ~JSONPView(); + /// Destructor + + bool render(Poco::JSON::Object::Ptr data, std::ostream& os); + /// Renders the JSON as JSONP + +private: + std::string _callback; +}; + +} } // Namespace MQ::Web + +#endif //_MQWeb_JSONPView_H diff --git a/MQWeb/src/Controller.cpp b/MQWeb/src/Controller.cpp index 84c366b..06b1ca7 100644 --- a/MQWeb/src/Controller.cpp +++ b/MQWeb/src/Controller.cpp @@ -21,6 +21,7 @@ #include #include "MQ/Web/Controller.h" +#include "MQ/Web/JSONPView.h" #include "MQ/MQSubsystem.h" #include "Poco/Util/Application.h" @@ -128,6 +129,12 @@ bool Controller::isJSON() const return result; } +void Controller::setJSONView() +{ + if ( _form.has("callback") ) setView(new JSONPView(_form.get("callback"))); + else if ( _form.has("jsonp") ) setView(new JSONPView(_form.get("jsonp"))); + else setView(new JSONView()); +} void Controller::render() { diff --git a/MQWeb/src/JSONPView.cpp b/MQWeb/src/JSONPView.cpp new file mode 100644 index 0000000..f8ba707 --- /dev/null +++ b/MQWeb/src/JSONPView.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or - as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/JSONPView.h" + +namespace MQ { +namespace Web { + +JSONPView::JSONPView(const std::string& callback) : JSONView(), _callback(callback) +{ +} + + +JSONPView::~JSONPView() +{ +} + +bool JSONPView::render(Poco::JSON::Object::Ptr data, std::ostream& os) +{ + os << _callback; + os << '('; + JSONView::render(data, os); + os << ");"; + return true; +} + + +}} // Namespace MQ::Web diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index 530b4ff..cdd6720 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -170,7 +170,7 @@ void MQController::handleException(const MQException& mqe) if ( isJSON() ) { - setView(new JSONView()); + setJSONView(); } else { From 19b65999ce1d0b118808cacb0680c014fe33bdfe Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 8 Aug 2014 19:09:06 +0200 Subject: [PATCH 018/143] Update ChangeLog --- ChangeLog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 3714ae3..c5ac1b1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,6 +3,9 @@ - Add inquire namelist (nl) - Add inquire process (process) - Add inquire service (service) + - Add inquire authentication information (authinfo) + - Add inquire authority record (authrec) + - Support for JSONP 0.0.10 - queueExcludeSystem/queueExcludeTemp renamed into excludeSystem/excludeTemp From 33b13221965fe0192331bcf9e7e5695cc5bfab2d Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 8 Aug 2014 22:48:27 +0200 Subject: [PATCH 019/143] No need to set JSON view, a JSON view is now set by default when no view is set --- MQWeb/src/AuthenticationInformationController.cpp | 3 +-- MQWeb/src/AuthorityRecordController.cpp | 3 +-- MQWeb/src/ChannelStatusController.cpp | 1 - MQWeb/src/ClusterQueueManagerController.cpp | 1 - MQWeb/src/ConnectionController.cpp | 1 - MQWeb/src/ListenerController.cpp | 1 - MQWeb/src/ListenerStatusController.cpp | 1 - MQWeb/src/MessageController.cpp | 6 ------ MQWeb/src/NamelistController.cpp | 1 - MQWeb/src/ProcessController.cpp | 1 - MQWeb/src/QueueManagerController.cpp | 1 - MQWeb/src/QueueManagerStatusController.cpp | 1 - MQWeb/src/QueueStatusController.cpp | 3 +-- MQWeb/src/ServiceController.cpp | 1 - 14 files changed, 3 insertions(+), 22 deletions(-) diff --git a/MQWeb/src/AuthenticationInformationController.cpp b/MQWeb/src/AuthenticationInformationController.cpp index a5dd4ba..522934d 100644 --- a/MQWeb/src/AuthenticationInformationController.cpp +++ b/MQWeb/src/AuthenticationInformationController.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or – as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the @@ -66,7 +66,6 @@ void AuthenticationInformationController::inquire() AuthenticationInformationMapper mapper(*commandServer()); Poco::JSON::Array::Ptr json = mapper.inquire(filter); set("authinfos", json); - setView(new JSONView()); } diff --git a/MQWeb/src/AuthorityRecordController.cpp b/MQWeb/src/AuthorityRecordController.cpp index 663fedc..3914eb8 100644 --- a/MQWeb/src/AuthorityRecordController.cpp +++ b/MQWeb/src/AuthorityRecordController.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or – as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the @@ -73,7 +73,6 @@ void AuthorityRecordController::inquire() AuthorityRecordMapper mapper(*commandServer()); Poco::JSON::Array::Ptr json = mapper.inquire(filter); set("authrecs", json); - setView(new JSONView()); } diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index 8b26760..445f20f 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -61,7 +61,6 @@ void ChannelStatusController::inquire() Poco::JSON::Array::Ptr statuses = channelStatusMapper.inquire(filter); set("statuses", statuses); - setView(new JSONView()); } diff --git a/MQWeb/src/ClusterQueueManagerController.cpp b/MQWeb/src/ClusterQueueManagerController.cpp index b71453d..7efa376 100644 --- a/MQWeb/src/ClusterQueueManagerController.cpp +++ b/MQWeb/src/ClusterQueueManagerController.cpp @@ -62,7 +62,6 @@ void ClusterQueueManagerController::inquire() ClusterQueueManagerMapper mapper(*commandServer()); Poco::JSON::Array::Ptr clusqmgrs = mapper.inquire(filter); set("clusqmgrs", clusqmgrs); - setView(new JSONView()); } diff --git a/MQWeb/src/ConnectionController.cpp b/MQWeb/src/ConnectionController.cpp index 37d0412..e18744d 100644 --- a/MQWeb/src/ConnectionController.cpp +++ b/MQWeb/src/ConnectionController.cpp @@ -54,7 +54,6 @@ void ConnectionController::inquire() ConnectionMapper mapper(*commandServer()); Poco::JSON::Array::Ptr json = mapper.inquire(filter); set("connections", json); - setView(new JSONView()); } diff --git a/MQWeb/src/ListenerController.cpp b/MQWeb/src/ListenerController.cpp index a8fae57..af0404b 100644 --- a/MQWeb/src/ListenerController.cpp +++ b/MQWeb/src/ListenerController.cpp @@ -67,7 +67,6 @@ void ListenerController::inquire() ListenerMapper mapper(*commandServer()); Poco::JSON::Array::Ptr listeners = mapper.inquire(filter); set("listeners", listeners); - setView(new JSONView()); } diff --git a/MQWeb/src/ListenerStatusController.cpp b/MQWeb/src/ListenerStatusController.cpp index 83bdc5e..c0b22f1 100644 --- a/MQWeb/src/ListenerStatusController.cpp +++ b/MQWeb/src/ListenerStatusController.cpp @@ -64,7 +64,6 @@ void ListenerStatusController::inquire() ListenerStatusMapper mapper(*commandServer()); Poco::JSON::Array::Ptr statuses = mapper.inquire(filter); set("statuses", statuses); - setView(new JSONView()); } diff --git a/MQWeb/src/MessageController.cpp b/MQWeb/src/MessageController.cpp index 6318cd6..7bb813b 100644 --- a/MQWeb/src/MessageController.cpp +++ b/MQWeb/src/MessageController.cpp @@ -270,8 +270,6 @@ void MessageController::browse() } set("messages", jsonMessages); - - setView(new JSONView()); } @@ -443,8 +441,6 @@ void MessageController::dump() mapMessageToJSON(message, *jsonMessage); set("message", jsonMessage); - - setView(new JSONView()); } @@ -573,8 +569,6 @@ void MessageController::event() count++; } - - setView(new JSONView()); } diff --git a/MQWeb/src/NamelistController.cpp b/MQWeb/src/NamelistController.cpp index 0cfc011..4042f4e 100644 --- a/MQWeb/src/NamelistController.cpp +++ b/MQWeb/src/NamelistController.cpp @@ -60,7 +60,6 @@ void NamelistController::inquire() NamelistMapper mapper(*commandServer()); Poco::JSON::Array::Ptr json = mapper.inquire(filter); set("namelists", json); - setView(new JSONView()); } diff --git a/MQWeb/src/ProcessController.cpp b/MQWeb/src/ProcessController.cpp index f70b674..4baac68 100644 --- a/MQWeb/src/ProcessController.cpp +++ b/MQWeb/src/ProcessController.cpp @@ -60,7 +60,6 @@ void ProcessController::inquire() ProcessMapper mapper(*commandServer()); Poco::JSON::Array::Ptr json = mapper.inquire(filter); set("processes", json); - setView(new JSONView()); } diff --git a/MQWeb/src/QueueManagerController.cpp b/MQWeb/src/QueueManagerController.cpp index 2ac1134..d101149 100644 --- a/MQWeb/src/QueueManagerController.cpp +++ b/MQWeb/src/QueueManagerController.cpp @@ -48,7 +48,6 @@ void QueueManagerController::inquire() if ( jsonQueueManagers->size() > 0 ) { set("qmgr", jsonQueueManagers->get(0)); - setView(new JSONView()); } } diff --git a/MQWeb/src/QueueManagerStatusController.cpp b/MQWeb/src/QueueManagerStatusController.cpp index c726616..b7daff6 100644 --- a/MQWeb/src/QueueManagerStatusController.cpp +++ b/MQWeb/src/QueueManagerStatusController.cpp @@ -55,7 +55,6 @@ void QueueManagerStatusController::inquire() if ( jsonQueueManagers->size() > 0 ) { set("status", jsonQueueManagers->get(0)); - setView(new JSONView()); } } diff --git a/MQWeb/src/QueueStatusController.cpp b/MQWeb/src/QueueStatusController.cpp index b44b2f9..7961ea2 100644 --- a/MQWeb/src/QueueStatusController.cpp +++ b/MQWeb/src/QueueStatusController.cpp @@ -1,7 +1,7 @@ /* * Copyright 2010 MQWeb - Franky Braem * - * Licensed under the EUPL, Version 1.1 or – as soon they + * Licensed under the EUPL, Version 1.1 or – as soon they * will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the @@ -68,7 +68,6 @@ void QueueStatusController::inquire() QueueStatusMapper mapper(*commandServer()); Poco::JSON::Array::Ptr json = mapper.inquire(filter); set("statuses", json); - setView(new JSONView()); } diff --git a/MQWeb/src/ServiceController.cpp b/MQWeb/src/ServiceController.cpp index 43e8c48..9fe501d 100644 --- a/MQWeb/src/ServiceController.cpp +++ b/MQWeb/src/ServiceController.cpp @@ -60,7 +60,6 @@ void ServiceController::inquire() ServiceMapper mapper(*commandServer()); Poco::JSON::Array::Ptr json = mapper.inquire(filter); set("services", json); - setView(new JSONView()); } From 8f81cdf520a5b0d8ff5d6f38ae346a43231bd8bd Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Mon, 11 Aug 2014 14:29:57 +0200 Subject: [PATCH 020/143] _nameMap wasn't filled --- MQWeb/include/MQ/Web/Dictionary.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MQWeb/include/MQ/Web/Dictionary.h b/MQWeb/include/MQ/Web/Dictionary.h index 0e59b3c..09c0623 100644 --- a/MQWeb/include/MQ/Web/Dictionary.h +++ b/MQWeb/include/MQ/Web/Dictionary.h @@ -137,11 +137,12 @@ inline std::map::const_iterator Dictionary::end() const inline void Dictionary::set(MQLONG id, const std::string& name) { _idMap[id] = name; + _nameMap[name] = id; } inline void Dictionary::set(MQLONG id, const std::string& name, const DisplayMap& displayMap) { - _idMap[id] = name; + set(id, name); _displayMaps[id] = displayMap; } From 25a6ce41d92eb452855e080ca72e9b1238fb6522 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Mon, 11 Aug 2014 14:40:32 +0200 Subject: [PATCH 021/143] Add addParameterList using a std::vector --- MQ/include/MQ/PCF.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MQ/include/MQ/PCF.h b/MQ/include/MQ/PCF.h index e9b01ce..28235e9 100644 --- a/MQ/include/MQ/PCF.h +++ b/MQ/include/MQ/PCF.h @@ -62,6 +62,9 @@ class PCF : public Message void addParameterList(MQLONG parameter, MQLONG *values); /// Add a numeric list parameter. + void addParameterList(MQLONG parameter, const std::vector& values); + /// Add a numeric list parameter + void addFilter(MQLONG parameter, MQLONG op, const std::string& value); /// Add a filter with a string value. @@ -174,6 +177,10 @@ class PCF : public Message /// Returns true when the parameter is of given type. }; +inline void PCF::addParameterList(MQLONG parameter, const std::vector& values) +{ + addParameterList(parameter, (MQLONG*) &values[0]); +} inline int PCF::getCommand() const { From be4ca3fcf5453c146b939ab2f2e11dada09701a8 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 11 Aug 2014 16:30:16 +0200 Subject: [PATCH 022/143] Filter on which attributes must be returned --- MQWeb/src/QueueController.cpp | 10 ++++++++++ MQWeb/src/QueueMapper.cpp | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index 2257361..f0a4f08 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -77,6 +77,16 @@ void QueueController::inquire() filter->set("excludeTemp", form().get("excludeTemp", "false").compare("true") == 0); } + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + filter->set("QAttrs", attrs); + + for(Poco::Net::NameValueCollection::ConstIterator itAttrs = form().find("Attrs"); + itAttrs != form().end() && Poco::icompare(itAttrs->first, "Attrs") == 0; + ++itAttrs) + { + attrs->add(itAttrs->second); + } + QueueMapper mapper(*commandServer()); Poco::JSON::Array::Ptr queues = mapper.inquire(filter); set("queues", queues); diff --git a/MQWeb/src/QueueMapper.cpp b/MQWeb/src/QueueMapper.cpp index 73d95fb..2e267f1 100644 --- a/MQWeb/src/QueueMapper.cpp +++ b/MQWeb/src/QueueMapper.cpp @@ -88,6 +88,21 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte } inquireQ->addParameter(MQIA_Q_TYPE, queueTypeValue); + if ( filter->has("QAttrs") ) + { + Poco::JSON::Array::Ptr attrs = filter->getArray("QAttrs"); + if ( !attrs.isNull() && attrs->size() > 0 ) + { + std::vector numList; + for(Poco::JSON::Array::ValueVec::const_iterator it = attrs->begin(); it != attrs->end(); ++it) + { + MQLONG id = dictionary()->getId(*it); + if ( id != -1 ) numList.push_back(id); + } + if ( numList.size() > 0 ) inquireQ->addParameterList(MQIACF_Q_ATTRS, numList); + } + } + PCF::Vector commandResponse; _commandServer.sendCommand(inquireQ, commandResponse); From ab900ad15a6791e6fbc2a52999b3b7be20113c4e Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 14 Aug 2014 18:32:15 +0200 Subject: [PATCH 023/143] Cleanup/Correct some attributes --- MQDictionary/src/Application.cpp | 293 ++++++++++++------------------- 1 file changed, 109 insertions(+), 184 deletions(-) diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 886e94c..5f1db21 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -130,6 +130,7 @@ Dictionary queueManagerDictionary = Dictionary() (MQIA_CLWL_USEQ, "CLWLUseQ", DisplayMapInitializer (MQCLWL_USEQ_ANY, "Any") (MQCLWL_USEQ_LOCAL, "Local") + (MQCLWL_USEQ_AS_Q_MGR, "AsQMgr") ) (MQIA_CODED_CHAR_SET_ID, "CodedCharSetID") (MQIA_COMMAND_EVENT, "CommandEvent", DisplayMapInitializer @@ -296,6 +297,7 @@ Dictionary queueManagerDictionary = Dictionary() (MQMON_NONE, "None") (MQMON_OFF, "Off") (MQMON_ON, "On") + (MQMON_Q_MGR, "Qmgr") ) (MQIA_MONITORING_Q, "QueueMonitoring", DisplayMapInitializer (MQMON_OFF, "Off") @@ -303,11 +305,13 @@ Dictionary queueManagerDictionary = Dictionary() (MQMON_LOW, "Low") (MQMON_MEDIUM, "Medium") (MQMON_HIGH, "High") + (MQMON_Q_MGR, "Qmgr") ) (MQIA_STATISTICS_Q, "QueueStatistics", DisplayMapInitializer (MQMON_NONE, "None") (MQMON_OFF, "Off") (MQMON_ON, "On") + (MQMON_Q_MGR, "Qmgr") ) (MQIA_RECEIVE_TIMEOUT, "ReceiveTimeout") (MQIA_RECEIVE_TIMEOUT_MIN, "ReceiveTimeoutMin") @@ -401,7 +405,7 @@ Dictionary queueManagerStatusDictionary = Dictionary() (MQCA_INSTALLATION_PATH, "InstallationPath") (MQCACF_LOG_PATH, "LogPath") (MQCACF_MEDIA_LOG_EXTENT_NAME, "MediaRecoveryLog") - (MQCA_Q_MGR_NAME, "QMgrName") + (MQCA_Q_MGR_NAME) (MQIACF_Q_MGR_STATUS, "QMgrStatus", DisplayMapInitializer (MQQMSTA_STARTING, "Starting") (MQQMSTA_RUNNING, "Running") @@ -415,17 +419,21 @@ Dictionary queueManagerStatusDictionary = Dictionary() (MQSTDBY_PERMITTED, "Permitted") ) // Extended Response - (MQBACF_RESPONSE_ID, "ResponseID") + (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary queueDictionary = Dictionary() - (MQCA_ALTERATION_DATE, "AlterationDate") - (MQCA_ALTERATION_TIME, "AlterationTime") + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) (MQCA_BACKOUT_REQ_Q_NAME, "BackoutRequeueName") (MQIA_BACKOUT_THRESHOLD, "BackoutThreshold") //(MQCA_BASE_Q_NAME, "BaseQName") (MQCA_BASE_OBJECT_NAME, "BaseObjectName") + (MQIA_BASE_TYPE, "BaseType", DisplayMapInitializer + (MQOT_Q, "Queue") + (MQOT_TOPIC, "Topic") + ) (MQCA_CF_STRUC_NAME, "CFStructure") #ifdef MQCA_CLUS_CHL_NAME (MQCA_CLUS_CHL_NAME, "ClusterChannelName") @@ -442,15 +450,11 @@ Dictionary queueDictionary = Dictionary() (MQCA_CLUSTER_TIME, "ClusterTime") (MQIA_CLWL_Q_PRIORITY, "CLWLQueuePriority") (MQIA_CLWL_Q_RANK, "CLWLQueueRank") - (MQIA_CLWL_USEQ, "CLWLUseQ", DisplayMapInitializer - (MQCLWL_USEQ_AS_Q_MGR, "Qmgr") - (MQCLWL_USEQ_ANY, "Any") - (MQCLWL_USEQ_LOCAL, "Local") - ) - (MQCA_CREATION_DATE, "CreationDate") - (MQCA_CREATION_TIME, "CreationTime") + (MQIA_CLWL_USEQ) + (MQCA_CREATION_DATE) + (MQCA_CREATION_TIME) (MQIA_CURRENT_Q_DEPTH, "CurrentQDepth") - (MQCA_CUSTOM, "Custom") + (MQCA_CUSTOM) (MQIA_DEF_PUT_RESPONSE_TYPE, "DefaultPutResponse", DisplayMapInitializer (MQPRT_SYNC_RESPONSE, "Sync") (MQPRT_ASYNC_RESPONSE, "Async") @@ -482,10 +486,7 @@ Dictionary queueDictionary = Dictionary() (MQREADA_YES, "Yes") (MQREADA_DISABLED, "Disabled") ) - (MQIA_DIST_LISTS, "DistLists", DisplayMapInitializer - (MQDL_SUPPORTED, "Supported") - (MQDL_NOT_SUPPORTED, "Not Supported") - ) + (MQIA_DIST_LISTS) (MQIA_HARDEN_GET_BACKOUT, "HardenGetBackout", DisplayMapInitializer (MQQA_BACKOUT_HARDENED, "Hardened") (MQQA_BACKOUT_NOT_HARDENED, "Not Hardened") @@ -506,7 +507,7 @@ Dictionary queueDictionary = Dictionary() (MQQA_PUT_INHIBITED, "Inhibited") ) (MQCA_INITIATION_Q_NAME, "InitiationQName") - (MQIA_MAX_MSG_LENGTH, "MaxMsgLength") + (MQIA_MAX_MSG_LENGTH) (MQIA_MAX_Q_DEPTH, "MaxQDepth") (MQIA_MSG_DELIVERY_SEQUENCE, "MsgDeliverySequence", DisplayMapInitializer (MQMDS_PRIORITY, "priority") @@ -541,8 +542,8 @@ Dictionary queueDictionary = Dictionary() (MQEVR_ENABLED, "Enabled") ) (MQCA_Q_DESC, "QDesc") - (MQCA_Q_MGR_IDENTIFIER, "QMgrIdentifier") - (MQCA_Q_MGR_NAME, "QMgrName") + (MQCA_Q_MGR_IDENTIFIER) + (MQCA_Q_MGR_NAME) (MQCA_Q_NAME, "QName") (MQIA_QSG_DISP, "QSGDisposition", DisplayMapInitializer (MQQSGD_COPY, "Copy") @@ -556,23 +557,9 @@ Dictionary queueDictionary = Dictionary() (MQQSIE_OK, "Ok") (MQQSIE_NONE, "None") ) - (MQIA_ACCOUNTING_Q, "QueueAccounting", DisplayMapInitializer - (MQMON_Q_MGR, "Qmgr") - (MQMON_OFF, "Off") - (MQMON_ON, "On") - ) - (MQIA_MONITORING_Q, "QueueMonitoring", DisplayMapInitializer - (MQMON_Q_MGR, "Qmgr") - (MQMON_OFF, "Off") - (MQMON_LOW, "Low") - (MQMON_MEDIUM, "Medium") - (MQMON_HIGH, "High") - ) - (MQIA_STATISTICS_Q, "QueueStatistics", DisplayMapInitializer - (MQMON_Q_MGR, "Qmgr") - (MQMON_OFF, "Off") - (MQMON_ON, "On") - ) + (MQIA_ACCOUNTING_Q) + (MQIA_MONITORING_Q) + (MQIA_STATISTICS_Q) (MQIA_Q_TYPE, "QType", DisplayMapInitializer (MQQT_ALL, "All") (MQQT_LOCAL, "Local") @@ -613,7 +600,7 @@ Dictionary queueDictionary = Dictionary() ) (MQCA_XMIT_Q_NAME, "XmitQName") // Extended Response - (MQBACF_RESPONSE_ID, "ResponseID") + (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; @@ -680,8 +667,8 @@ Dictionary queueStatusDictionary = Dictionary() (MQAS_SUSPENDED_TEMPORARY, "Suspended Temporary") (MQAS_NONE, "None") ) - (MQCACH_CHANNEL_NAME, "") - (MQCACH_CONNECTION_NAME, "") + (MQCACH_CHANNEL_NAME, "ChannelName") + (MQCACH_CONNECTION_NAME) (MQBACF_EXTERNAL_UOW_ID, "ExternalUOWId") (MQIACF_HANDLE_STATE, "HandleState", DisplayMapInitializer (MQHSTATE_ACTIVE, "Active") @@ -713,8 +700,8 @@ Dictionary queueStatusDictionary = Dictionary() (MQCACF_PSB_NAME, "PSBName") (MQCACF_PST_ID, "PSTId") (MQBACF_Q_MGR_UOW_ID, "QMgrUOWId") - (MQCA_Q_NAME, "") - (MQIA_QSG_DISP, "") + (MQCA_Q_NAME) + (MQIA_QSG_DISP) (MQIACF_Q_STATUS_TYPE, "StatusType", DisplayMapInitializer (MQIACF_Q_STATUS, "Queue Status") (MQIACF_Q_HANDLE, "Handle") @@ -731,11 +718,14 @@ Dictionary queueStatusDictionary = Dictionary() (MQUOWT_XA, "XA") ) (MQCACF_USER_IDENTIFIER) + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary channelDictionary = Dictionary() - (MQCA_ALTERATION_DATE, "AlterationDate") - (MQCA_ALTERATION_TIME, "AlterationTime") + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) (MQIACH_BATCH_HB, "BatchHeartBeat") (MQIACH_BATCH_INTERVAL, "BatchInterval") #ifdef MQIACH_BATCH_DATA_LIMIT @@ -743,23 +733,11 @@ Dictionary channelDictionary = Dictionary() #endif (MQIACH_BATCH_SIZE, "BatchSize") (MQCACH_DESC, "ChannelDesc") - (MQIA_MONITORING_CHANNEL, "ChannelMonitoring", DisplayMapInitializer - (MQMON_OFF, "Off") - (MQMON_Q_MGR, "Qmgr") - (MQMON_LOW, "Low") - (MQMON_MEDIUM, "Medium") - (MQMON_HIGH, "High") - ) - (MQCACH_CHANNEL_NAME, "ChannelName") + (MQIA_MONITORING_CHANNEL) + (MQCACH_CHANNEL_NAME) (MQCACH_CHANNEL_START_DATE, "ChannelStartDate") (MQCACH_CHANNEL_START_TIME, "ChannelStartTime") - (MQIA_STATISTICS_CHANNEL, "ChannelStatistics", DisplayMapInitializer - (MQMON_OFF, "Off") - (MQMON_Q_MGR, "Qmgr") - (MQMON_LOW, "Low") - (MQMON_MEDIUM, "Medium") - (MQMON_HIGH, "High") - ) + (MQIA_STATISTICS_CHANNEL) (MQIACH_CHANNEL_TYPE, "ChannelType", DisplayMapInitializer (MQCHT_ALL, "All") (MQCHT_SENDER, "Sender") @@ -778,8 +756,8 @@ Dictionary channelDictionary = Dictionary() #ifdef MQCACH_CLIENT_ID (MQCACH_CLIENT_ID, "ClientIdentifier") #endif - (MQCA_CLUSTER_NAME, "ClusterName") - (MQCA_CLUSTER_NAMELIST, "ClusterNamelist") + (MQCA_CLUSTER_NAME) + (MQCA_CLUSTER_NAMELIST) (MQIACH_CLWL_CHANNEL_PRIORITY, "CLWLChannelPriority") (MQIACH_CLWL_CHANNEL_RANK, "CLWLChannelRank") (MQIACH_CLWL_CHANNEL_WEIGHT, "CLWLChannelWeight") @@ -877,13 +855,8 @@ Dictionary channelDictionary = Dictionary() (MQPA_DEFAULT, "Default") (MQPA_CONTEXT, "Context") ) - (MQCA_Q_MGR_NAME, "QMgrName") - (MQIA_QSG_DISP, "QSGDisposition", DisplayMapInitializer - (MQQSGD_COPY, "Copy") - (MQQSGD_GROUP, "Group") - (MQQSGD_Q_MGR, "Qmgr") - (MQQSGD_SHARED, "Shared") - ) + (MQCA_Q_MGR_NAME) + (MQIA_QSG_DISP) (MQCACH_RCV_EXIT_NAME, "ReceiveExit") (MQCACH_RCV_EXIT_USER_DATA, "ReceiveUserData") (MQCACH_SEC_EXIT_NAME, "SecurityExit") @@ -920,11 +893,14 @@ Dictionary channelDictionary = Dictionary() #endif (MQCACH_USER_ID, "UserIdentifier") (MQCACH_XMIT_Q_NAME, "XmitQName") + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary channelStatusDictionary = Dictionary() (MQIACH_BATCHES, "Batches") - (MQIACH_BATCH_SIZE, "BatchSize") + (MQIACH_BATCH_SIZE) (MQIACH_BATCH_SIZE_INDICATOR, "BatchSizeIndicator") (MQIACH_BUFFERS_RCVD, "BuffersReceived") (MQIACH_BUFFERS_SENT, "BuffersSent") @@ -941,16 +917,10 @@ Dictionary channelStatusDictionary = Dictionary() (MQOT_SAVED_CHANNEL, "Saved") (MQOT_SHORT_CHANNEL, "Short") ) - (MQIA_MONITORING_CHANNEL, "ChannelMonitoring", DisplayMapInitializer - (MQMON_OFF, "Off") - (MQMON_Q_MGR, "Qmgr") - (MQMON_LOW, "Low") - (MQMON_MEDIUM, "Medium") - (MQMON_HIGH, "High") - ) - (MQCACH_CHANNEL_NAME, "ChannelName") - (MQCACH_CHANNEL_START_DATE, "ChannelStartDate") - (MQCACH_CHANNEL_START_TIME, "ChannelStartTime") + (MQIA_MONITORING_CHANNEL) + (MQCACH_CHANNEL_NAME) + (MQCACH_CHANNEL_START_DATE) + (MQCACH_CHANNEL_START_TIME) (MQIACH_CHANNEL_STATUS, "ChannelStatus", DisplayMapInitializer (MQCHS_BINDING, "Binding") (MQCHS_STARTING, "Starting") @@ -963,23 +933,10 @@ Dictionary channelStatusDictionary = Dictionary() (MQCHS_INITIALIZING, "Initializing") (MQCHS_INACTIVE, "Inactive") ) - (MQIACH_CHANNEL_TYPE, "ChannelType", DisplayMapInitializer - (MQCHT_ALL, "All") - (MQCHT_SENDER, "Sender") - (MQCHT_SERVER, "Server") - (MQCHT_RECEIVER, "Receiver") - (MQCHT_REQUESTER, "Requester") - (MQCHT_SVRCONN, "Server-connection") - (MQCHT_CLNTCONN, "Client-connection") - (MQCHT_CLUSRCVR, "Cluster-receiver") - (MQCHT_CLUSSDR, "Cluster-sender") -#ifdef MQCHT_MQTT - (MQCHT_MQTT, "Telemetry") -#endif - ) + (MQIACH_CHANNEL_TYPE) (MQIACH_COMPRESSION_RATE, "CompressionRate") (MQIACH_COMPRESSION_TIME, "CompressionTime") - (MQCACH_CONNECTION_NAME, "ConnectionName") + (MQCACH_CONNECTION_NAME) (MQCACH_CURRENT_LUWID, "CurrentLUWID") (MQIACH_CURRENT_MSGS, "CurrentMsgs") (MQIACH_CURRENT_SEQ_NUMBER, "CurrentSequenceNumber") @@ -1025,7 +982,7 @@ Dictionary channelStatusDictionary = Dictionary() (MQNPMS_FAST, "Fast") (MQNPMS_NORMAL, "Normal") ) - (MQCA_Q_MGR_NAME, "QMgrName") + (MQCA_Q_MGR_NAME) (MQCACH_REMOTE_APPL_TAG, "RemoteApplTag") #ifdef MQCACH_REMOTE_PRODUCT (MQCACH_REMOTE_PRODUCT, "RemoteProduct", DisplayMapInitializer @@ -1071,7 +1028,7 @@ Dictionary channelStatusDictionary = Dictionary() #ifdef MQCACH_REMOTE_VERSION (MQCACH_REMOTE_VERSION, "RemoteVersion") #endif - (MQCA_REMOTE_Q_MGR_NAME, "RemoteQMgrName") + (MQCA_REMOTE_Q_MGR_NAME) (MQIACH_SHORT_RETRIES_LEFT, "ShortRetriesLeft") (MQCACH_SSL_CERT_ISSUER_NAME, "SSLCertRemoteIssuerName") (MQCACH_SSL_CERT_USER_ID, "SSLCertUserId") @@ -1111,43 +1068,26 @@ Dictionary channelStatusDictionary = Dictionary() (MQCHSSTATE_SENDING, "Sending") (MQCHSSTATE_SERIALIZING, "Serializing") ) - (MQCACH_XMIT_Q_NAME, "XmitQName") + (MQCACH_XMIT_Q_NAME) (MQIACH_XMITQ_TIME_INDICATOR, "XQTime") // Extended Response - (MQBACF_RESPONSE_ID, "ResponseID") + (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary clusterQueueManagerDictionary = Dictionary() - (MQCA_ALTERATION_DATE, "AlterationDate") - (MQCA_ALTERATION_TIME, "AlterationTime") - (MQIACH_BATCH_HB, "BatchHeartBeat") - (MQIACH_BATCH_INTERVAL, "BatchInterval") - (MQIACH_BATCH_SIZE, "BatchSize") - (MQCACH_DESC, "ChannelDesc") - (MQIA_MONITORING_CHANNEL, "ChannelMonitoring", DisplayMapInitializer - (MQMON_OFF, "Off") - (MQMON_Q_MGR, "Qmgr") - (MQMON_LOW, "Low") - (MQMON_MEDIUM, "Medium") - (MQMON_HIGH, "High") - ) - (MQCACH_CHANNEL_NAME, "ChannelName") - (MQIACH_CHANNEL_STATUS, "ChannelStatus", DisplayMapInitializer - (MQCHS_BINDING, "Binding") - (MQCHS_STARTING, "Starting") - (MQCHS_RUNNING, "Running") - (MQCHS_PAUSED, "Paused") - (MQCHS_STOPPING, "Stopping") - (MQCHS_STOPPED, "Stopped") - (MQCHS_RETRYING, "Retrying") - (MQCHS_REQUESTING, "Requesting") - (MQCHS_INITIALIZING, "Initializing") - (MQCHS_INACTIVE, "Inactive") - ) - (MQCA_CLUSTER_DATE, "ClusterDate") - (MQCA_CLUSTER_NAME, "ClusterName") - (MQCA_CLUSTER_TIME, "ClusterTime") + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) + (MQIACH_BATCH_HB) + (MQIACH_BATCH_INTERVAL) + (MQIACH_BATCH_SIZE) + (MQCACH_DESC) + (MQIA_MONITORING_CHANNEL) + (MQCACH_CHANNEL_NAME) + (MQIACH_CHANNEL_STATUS) + (MQCA_CLUSTER_DATE) + (MQCA_CLUSTER_NAME) + (MQCA_CLUSTER_TIME) (MQIACH_CLWL_CHANNEL_PRIORITY, "CLWLChannelPriority") (MQIACH_CLWL_CHANNEL_RANK, "CLWLChannelRank") (MQIACH_CLWL_CHANNEL_WEIGHT, "CLWLChannelWeight") @@ -1210,7 +1150,7 @@ Dictionary clusterQueueManagerDictionary = Dictionary() (MQQMDT_CLUSTER_RECEIVER, "Cluster Receiver") (MQQMDT_AUTO_EXP_CLUSTER_SENDER, "Auto Exp Cluster Sender") ) - (MQCA_Q_MGR_IDENTIFIER, "QMgrIdentifier") + (MQCA_Q_MGR_IDENTIFIER) (MQCA_CLUSTER_Q_MGR_NAME, "QMgrName") (MQIACF_Q_MGR_TYPE, "QMgrType", DisplayMapInitializer (MQQMT_NORMAL, "Normal") @@ -1235,26 +1175,17 @@ Dictionary clusterQueueManagerDictionary = Dictionary() (MQSUS_NO, "No") (MQSUS_YES, "Yes") ) - (MQCACH_TP_NAME, "TpName") - (MQCA_XMIT_Q_NAME, "XmitQ") - (MQIACH_XMIT_PROTOCOL_TYPE, "TransportType", DisplayMapInitializer - (MQXPT_ALL, "All") - (MQXPT_LOCAL, "Local") - (MQXPT_LU62, "LU62") - (MQXPT_TCP, "TCP") - (MQXPT_NETBIOS, "NetBIOS") - (MQXPT_SPX, "SPX") - (MQXPT_DECNET, "DECnet") - (MQXPT_UDP, "UDP") - ) - (MQCACH_USER_ID, "UserIdentifier") + (MQCACH_TP_NAME) + (MQCA_XMIT_Q_NAME) + (MQIACH_XMIT_PROTOCOL_TYPE) + (MQCACH_USER_ID) // Extended Response - (MQBACF_RESPONSE_ID, "ResponseID") + (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary connectionDictionary = Dictionary() - (MQIA_APPL_TYPE, "") + (MQIA_APPL_TYPE) (MQBACF_CONNECTION_ID, "ConnectionId") (MQIACF_CONN_INFO_TYPE, "ConnInfoType", DisplayMapInitializer (MQIACF_CONN_INFO_CONN, "Generic Information") @@ -1262,14 +1193,14 @@ Dictionary connectionDictionary = Dictionary() ) (MQBACF_GENERIC_CONNECTION_ID, "GenericConnectionId") // Extended Response - (MQBACF_RESPONSE_ID, "ResponseID") + (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary listenerDictionary = Dictionary() (MQIACH_ADAPTER, "Adapter") - (MQCA_ALTERATION_DATE, "AlterationDate") - (MQCA_ALTERATION_TIME, "AlterationTime") + (MQCA_ALTERATION_DATE) + (MQCA_ALTERATION_TIME) (MQIACH_BACKLOG, "Backlog") (MQIACH_COMMAND_COUNT, "Commands") (MQCACH_IP_ADDRESS, "IPAddress") @@ -1286,19 +1217,10 @@ Dictionary listenerDictionary = Dictionary() (MQSVC_CONTROL_Q_MGR, "Qmgr") (MQSVC_CONTROL_Q_MGR_START, "Qmgr Start") ) - (MQCACH_TP_NAME, "TPName") - (MQIACH_XMIT_PROTOCOL_TYPE, "TransportType", DisplayMapInitializer - (MQXPT_ALL, "All") - (MQXPT_LOCAL, "Local") - (MQXPT_LU62, "LU62") - (MQXPT_TCP, "TCP") - (MQXPT_NETBIOS, "NetBIOS") - (MQXPT_SPX, "SPX") - (MQXPT_DECNET, "DECnet") - (MQXPT_UDP, "UDP") - ) + (MQCACH_TP_NAME) + (MQIACH_XMIT_PROTOCOL_TYPE) // Extended Response - (MQBACF_RESPONSE_ID, "ResponseID") + (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; @@ -1326,19 +1248,10 @@ Dictionary listenerStatusDictionary = Dictionary() (MQSVC_STATUS_RUNNING, "Running") (MQSVC_STATUS_STOPPING, "Stopping") ) - (MQCACH_TP_NAME, "TPName") - (MQIACH_XMIT_PROTOCOL_TYPE, "TransportType", DisplayMapInitializer - (MQXPT_ALL, "All") - (MQXPT_LOCAL, "Local") - (MQXPT_LU62, "LU62") - (MQXPT_TCP, "TCP") - (MQXPT_NETBIOS, "NetBIOS") - (MQXPT_SPX, "SPX") - (MQXPT_DECNET, "DECnet") - (MQXPT_UDP, "UDP") - ) + (MQCACH_TP_NAME) + (MQIACH_XMIT_PROTOCOL_TYPE) // Extended Response - (MQBACF_RESPONSE_ID, "ResponseID") + (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; @@ -1417,11 +1330,14 @@ Dictionary topicDictionary = Dictionary() (MQTA_PASSTHRU, "Passthru") (MQTA_BLOCK, "Block") ) + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary eventDictionary = Dictionary() (MQCA_ADMIN_TOPIC_NAME, "AdminTopicNames") - (MQIA_APPL_TYPE, "") + (MQIA_APPL_TYPE) (MQCACF_APPL_NAME, "ApplName") (MQCA_AUTH_INFO_NAME, "AuthInfoName") (MQIACF_AUX_ERROR_DATA_INT_1, "AuxErrorDataInt1") @@ -1430,17 +1346,14 @@ Dictionary eventDictionary = Dictionary() (MQCACF_AUX_ERROR_DATA_STR_2, "AuxErrorDataStr2") (MQCACF_AUX_ERROR_DATA_STR_3, "AuxErrorDataStr3") (MQCA_BASE_OBJECT_NAME, "BaseObjectName") - (MQIA_BASE_TYPE, "BaseType", DisplayMapInitializer - (MQOT_Q, "Queue") - (MQOT_TOPIC, "Topic") - ) + (MQIA_BASE_TYPE) (MQCACF_BRIDGE_NAME, "BridgeName") (MQIACF_BRIDGE_TYPE, "BridgeType", DisplayMapInitializer (MQBT_OTMA, "OTMA") ) (MQCA_CF_STRUC_NAME, "CFStrucName") - (MQCACH_CHANNEL_NAME, "ChannelName") - (MQIACH_CHANNEL_TYPE, "ChannelType") + (MQCACH_CHANNEL_NAME) + (MQIACH_CHANNEL_TYPE) (MQCACH_CLIENT_USER_ID, "ClientUserIdentifier") (MQIACF_COMMAND, "Command", DisplayMapInitializer MQCONST2STR(MQCMD_ARCHIVE_LOG) @@ -1637,8 +1550,8 @@ Dictionary eventDictionary = Dictionary() (MQCACH_LISTENER_NAME, "ListenerName") (MQCACF_LOG_PATH, "LogPath") (MQCA_NAMELIST_NAME, "NamelistName") - (MQIA_ACTIVE_CHANNELS, "MaximumActiveChannels") - (MQIA_MAX_CHANNELS, "MaximumChannels") + (MQIA_ACTIVE_CHANNELS) + (MQIA_MAX_CHANNELS) (MQIACH_MAX_INSTS_PER_CLIENT, "MaximumClientInstances") (MQIACH_MAX_INSTANCES, "MaximumInstances") (MQCACF_MEDIA_LOG_EXTENT_NAME, "MediaLogExtentName") @@ -1681,13 +1594,13 @@ Dictionary eventDictionary = Dictionary() (MQIACF_OPEN_OPTIONS, "OpenOptions") (MQCA_PROCESS_NAME, "ProcessName") (MQCA_Q_NAME, "QName") - (MQCA_Q_MGR_NAME, "QMgrName") - (MQIA_QSG_DISP, "QSGDisposition") - (MQIA_Q_TYPE, "QType") + (MQCA_Q_MGR_NAME) + (MQIA_QSG_DISP) + (MQIA_Q_TYPE) (MQCACH_SSL_HANDSHAKE_STAGE, "SSLHandshakeStage") (MQCACH_SSL_PEER_NAME, "SSLPeerName") (MQIACH_SSL_RETURN_CODE, "SSLReturnCode") - (MQCA_STORAGE_CLASS, "StorageClass") + (MQCA_STORAGE_CLASS) (MQCACF_SUB_NAME, "SubName") (MQIACF_SUB_OPTIONS, "SubOptions") (MQIA_TIME_SINCE_RESET, "TimeSinceReset") @@ -1725,7 +1638,7 @@ Dictionary eventDictionary = Dictionary() ) (MQCACF_RESTART_LOG_EXTENT_NAME, "RestartRecoveryLogExtent") (MQCACF_USER_IDENTIFIER, "UserIdentifier") - (MQCACH_XMIT_Q_NAME, "XmitQName") + (MQCACH_XMIT_Q_NAME) ; Dictionary reasonDictionary = Dictionary() @@ -2287,6 +2200,9 @@ Dictionary processDictionary = Dictionary() (MQCA_PROCESS_NAME) (MQIA_QSG_DISP) (MQCA_USER_DATA, "UserData") + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary serviceDictionary = Dictionary() @@ -2309,6 +2225,9 @@ Dictionary serviceDictionary = Dictionary() (MQCA_STDOUT_DESTINATION, "StdoutDestination") (MQCA_SERVICE_STOP_ARGS, "StopArguments") (MQCA_SERVICE_STOP_COMMAND, "StopCommand") + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary authenticationInformationDictionary = Dictionary() @@ -2326,6 +2245,9 @@ Dictionary authenticationInformationDictionary = Dictionary() (MQCA_LDAP_USER_NAME, "LDAPUserName") (MQCA_AUTH_INFO_OCSP_URL, "OCSPResponderURL") (MQIA_QSG_DISP) + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary authorityRecordDictionary = Dictionary() @@ -2366,7 +2288,10 @@ Dictionary authorityRecordDictionary = Dictionary() (MQIACF_OBJECT_TYPE) (MQIACF_AUTH_OPTIONS, "Options") (MQCACF_AUTH_PROFILE_NAME, "ProfileName") - (MQCA_Q_MGR_NAME, "QMgrName") + (MQCA_Q_MGR_NAME) + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; class MQDictionary : public Poco::Util::Application From 50aace3ab021028838689190684d9e19a9c2b957 Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 14 Aug 2014 18:32:47 +0200 Subject: [PATCH 024/143] Add method for resolving operator and handling integer/string filter --- MQWeb/include/MQ/Web/MQMapper.h | 10 +++++ MQWeb/src/MQMapper.cpp | 73 +++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/MQWeb/include/MQ/Web/MQMapper.h b/MQWeb/include/MQ/Web/MQMapper.h index bf383ef..8c46c23 100644 --- a/MQWeb/include/MQ/Web/MQMapper.h +++ b/MQWeb/include/MQ/Web/MQMapper.h @@ -43,6 +43,10 @@ class MQMapper : public Mapper /// Destructor const Poco::SharedPtr dictionary() const; + /// Returns the dictionary for the associated object type + + static MQLONG getOperator(const std::string& op); + /// Returns the string equivalent for an operator static std::string getReasonString(MQLONG reasonCode); /// Translates a reason code into a string @@ -53,6 +57,12 @@ class MQMapper : public Mapper static const Poco::SharedPtr dictionary(const std::string& objectType); /// Returns the dictionary for the given object type + void handleIntegerFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter); + /// When IntegerFilterCommand is set, it will add an integer filter to the PCF message + + void handleStringFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter); + /// When StringFilterCommand is set, it will add an string filter to the PCF message + protected: MQ::CommandServer& _commandServer; diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index d28958b..3ac20f0 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -53,6 +53,26 @@ std::string MQMapper::getReasonString(MQLONG reasonCode) return dict->getDisplayValue(MQIACF_REASON_CODE, reasonCode); } +MQLONG MQMapper::getOperator(const std::string& op) +{ + static Dictionary operators = Dictionary() + (MQCFOP_LESS, "LT") + (MQCFOP_LESS | MQCFOP_EQUAL, "LE") + (MQCFOP_EQUAL, "EQ") + (MQCFOP_GREATER, "GT") + (MQCFOP_GREATER | MQCFOP_EQUAL, "GE") + (MQCFOP_NOT_LESS, "NLT") + (MQCFOP_NOT_EQUAL, "NE") + (MQCFOP_NOT_GREATER, "NGT") + (MQCFOP_LIKE, "LK") + (MQCFOP_NOT_LIKE, "NL") + (MQCFOP_CONTAINS, "CT") + (MQCFOP_EXCLUDES, "EX") + (MQCFOP_CONTAINS_GEN, "CTG") + (MQCFOP_EXCLUDES_GEN, "EXG") + ; + return operators.getId(op); +} const DisplayMap& MQMapper::getDisplayMap(const std::string& objectType, MQLONG id) { @@ -68,5 +88,58 @@ const DisplayMap& MQMapper::getDisplayMap(const std::string& objectType, MQLONG return dict->getDisplayMap(id); } +void MQMapper::handleIntegerFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter) +{ + if ( filter->has("IntegerFilterCommand") ) + { + Poco::JSON::Object::Ptr integerFilterCommand = filter->getObject("IntegerFilterCommand"); + if ( !integerFilterCommand.isNull() ) + { + std::string parameterName = integerFilterCommand->optValue("Parameter", ""); + MQLONG parameter = dictionary()->getId(parameterName); + if ( parameter != -1 ) + { + std::string opString = integerFilterCommand->optValue("Operator", "EQ"); + MQLONG op = getOperator(Poco::toUpper(opString)); + if ( op == -1 ) op = MQCFOP_EQUAL; + + Poco::Dynamic::Var value = integerFilterCommand->get("FilterValue"); + MQLONG filterValue; + if ( value.isString() ) + { + // A String is passed ... try to find the MQ integer value + filterValue = dictionary()->getDisplayId(parameter, value); + } + else if ( value.isNumeric() ) + { + filterValue = value; + } + pcf->addFilter(parameter, op, filterValue); + } + } + } +} + +void MQMapper::handleStringFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter) +{ + if ( filter->has("StringFilterCommand") ) + { + Poco::JSON::Object::Ptr integerFilterCommand = filter->getObject("StringFilterCommand"); + if ( !integerFilterCommand.isNull() ) + { + std::string parameterName = integerFilterCommand->optValue("Parameter", ""); + MQLONG parameter = dictionary()->getId(parameterName); + if ( parameter != -1 ) + { + std::string opString = integerFilterCommand->optValue("Operator", "EQ"); + MQLONG op = getOperator(Poco::toUpper(opString)); + if ( op == -1 ) op = MQCFOP_EQUAL; + + std::string filterValue = integerFilterCommand->optValue("FilterValue", ""); + pcf->addFilter(parameter, op, filterValue); + } + } + } +} }} // Namespace MQ::Web From 1deea146e12e81062640cf55fdc20f981d3b8e82 Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 14 Aug 2014 18:33:24 +0200 Subject: [PATCH 025/143] Make it possible to POST JSON --- MQWeb/src/Controller.cpp | 30 ++++++++++- MQWeb/src/QueueController.cpp | 95 ++++++++++++++++++++++++----------- MQWeb/src/QueueMapper.cpp | 24 ++++----- 3 files changed, 106 insertions(+), 43 deletions(-) diff --git a/MQWeb/src/Controller.cpp b/MQWeb/src/Controller.cpp index 06b1ca7..835e43f 100644 --- a/MQWeb/src/Controller.cpp +++ b/MQWeb/src/Controller.cpp @@ -29,7 +29,7 @@ #include "Poco/StreamCopier.h" #include "Poco/URI.h" -#include "Poco/JSON/TemplateCache.h" +#include "Poco/JSON/Parser.h" namespace MQ { @@ -80,7 +80,33 @@ void Controller::handle(const std::vector& parameters, Poco::Net::H } } - _form.load(request, request.stream(), *this); + std::string contentType = request.getContentType(); + if ( contentType == "application/json" ) + { + Poco::JSON::Parser parser; + try + { + Poco::Dynamic::Var json = parser.parse(request.stream()); + if ( ! json.isEmpty() && json.type() == typeid(Poco::JSON::Object::Ptr) ) + { + _data->set("filter", json.extract()); + } + } + catch(Poco::JSON::JSONException& jsone) + { + // Make sure everything is read, otherwise this can result + // in Bad Request error in the next call. + Poco::NullOutputStream nos; + Poco::StreamCopier::copyStream(request.stream(), nos); + + setResponseStatus(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST, "JSON error occurred: " + jsone.displayText()); + return; + } + } + else + { + _form.load(request, request.stream(), *this); + } // Make sure everything is read, otherwise this can result // in Bad Request error in the next call. diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index f0a4f08..95f0cff 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -40,55 +40,92 @@ QueueController::~QueueController() void QueueController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a queuename and will result in inquiring - // only that queue and ignores all query parameters. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("name", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - // Handle query parameters - std::string queueNameField = form().get("queueName", "*"); - if ( queueNameField.empty() ) + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a queuename and will result in inquiring + // only that queue and ignores all query parameters. + if ( parameters.size() > 1 ) { - queueNameField = "*"; + pcfParameters->set("QName", parameters[1]); + } + else + { + // Handle query parameters + std::string queueNameField; + if ( form().has("QName") ) + { + queueNameField = form().get("QName"); + } + else + { + queueNameField = form().get("queueName", "*"); + } + if ( queueNameField.empty() ) + { + queueNameField = "*"; + } + pcfParameters->set("QName", queueNameField); } - filter->set("name", queueNameField); - std::string queueDepthField = form().get("queueDepth", ""); - int queueDepth = 0; - if ( Poco::NumberParser::tryParse(queueDepthField, queueDepth) ) + std::string queueDepthField; + if ( form().has("CurrentQDepth") ) + { + queueDepthField = form().get("CurrentQDepth", ""); + } + else if ( form().has("queueDepth")) + { + queueDepthField = form().get("queueDepth", ""); + } + if ( !queueDepthField.empty() ) { - filter->set("qdepth", queueDepth); + int queueDepth = 0; + if ( Poco::NumberParser::tryParse(queueDepthField, queueDepth) ) + { + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + filter->set("Parameter", "CurrentQDepth"); + filter->set("Operator", "NLT"); //Not Less + filter->set("FilterValue", queueDepth); + pcfParameters->set("IntegerFilterCommand", filter); + } } if ( form().has("queueUsage") ) { - filter->set("usage", form().get("queueUsage")); + pcfParameters->set("Usage", form().get("queueUsage")); + } + else if ( form().has("Usage") ) + { + pcfParameters->set("Usage", form().get("Usage")); } - filter->set("type", form().get("queueType", "All")); - filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); - filter->set("excludeTemp", form().get("excludeTemp", "false").compare("true") == 0); - } + pcfParameters->set("QType", form().get("queueType", "All")); + pcfParameters->set("ExcludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + pcfParameters->set("ExcludeTemp", form().get("excludeTemp", "false").compare("true") == 0); - Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); - filter->set("QAttrs", attrs); + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + pcfParameters->set("QAttrs", attrs); - for(Poco::Net::NameValueCollection::ConstIterator itAttrs = form().find("Attrs"); - itAttrs != form().end() && Poco::icompare(itAttrs->first, "Attrs") == 0; - ++itAttrs) - { - attrs->add(itAttrs->second); + for(Poco::Net::NameValueCollection::ConstIterator itAttrs = form().find("Attrs"); + itAttrs != form().end() && Poco::icompare(itAttrs->first, "Attrs") == 0; + ++itAttrs) + { + attrs->add(itAttrs->second); + } } QueueMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr queues = mapper.inquire(filter); + Poco::JSON::Array::Ptr queues = mapper.inquire(pcfParameters); set("queues", queues); setView(new JSONView()); } diff --git a/MQWeb/src/QueueMapper.cpp b/MQWeb/src/QueueMapper.cpp index 2e267f1..f42be7e 100644 --- a/MQWeb/src/QueueMapper.cpp +++ b/MQWeb/src/QueueMapper.cpp @@ -59,27 +59,27 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte Poco::JSON::Array::Ptr jsonQueues = new Poco::JSON::Array(); PCF::Ptr inquireQ = _commandServer.createCommand(MQCMD_INQUIRE_Q); - inquireQ->addParameter(MQCA_Q_NAME, filter->optValue("name", "*")); - if ( filter->has("qdepth") ) - { - inquireQ->addFilter(MQIA_CURRENT_Q_DEPTH, MQCFOP_NOT_LESS, filter->getValue("qdepth")); - } + inquireQ->addParameter(MQCA_Q_NAME, filter->optValue("QName", "*")); + + handleIntegerFilter(inquireQ, filter); + handleStringFilter(inquireQ, filter); MQLONG usage = -1; - if ( filter->has("usage") ) + if ( filter->has("Usage") ) { - std::string usageValue = filter->optValue("usage", ""); - if ( usageValue.compare("xmitq") == 0 ) + std::string usageValue = filter->optValue("Usage", ""); + if ( Poco::icompare(usageValue, "Transmission") == 0 + || Poco::icompare(usageValue, "XmitQ") == 0 ) { usage = MQUS_TRANSMISSION; } - else if ( usageValue.compare("normal") == 0 ) + else if ( Poco::icompare(usageValue, "Normal") == 0 ) { usage = MQUS_NORMAL; } } - std::string queueType = filter->optValue("type", "All"); + std::string queueType = filter->optValue("QType", "All"); MQLONG queueTypeValue = dictionary()->getDisplayId(MQIA_Q_TYPE, queueType); poco_assert_dbg(queueTypeValue != -1); if ( queueTypeValue == - 1 ) @@ -106,8 +106,8 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte PCF::Vector commandResponse; _commandServer.sendCommand(inquireQ, commandResponse); - bool excludeSystem = filter->optValue("excludeSystem", false); - bool excludeTemp = filter->optValue("excludeTemp", false); + bool excludeSystem = filter->optValue("ExcludeSystem", false); + bool excludeTemp = filter->optValue("ExcludeTemp", false); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { From 22052b2db1c16655e0b2870a5e9611efe3bc93d6 Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 14 Aug 2014 18:33:38 +0200 Subject: [PATCH 026/143] Add test for POST JSON --- test/queue.py | 17 +++++++++++++++++ test/testbase.py | 18 ++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/test/queue.py b/test/queue.py index 2030a38..eb2b030 100644 --- a/test/queue.py +++ b/test/queue.py @@ -1,8 +1,10 @@ import unittest +import json from testbase import MQWebTest class TestQueueActions(MQWebTest): + """ def testInquire(self): data = self.getJSON('/api/queue/inquire/' + self.qmgr) @@ -15,6 +17,21 @@ def testInquire(self): self.assertFalse('queues' not in data, 'No queues returned') self.assertTrue(self.checkIds(data['queues'][0]), 'There are unmapped Websphere MQ attributes') + print json.dumps(data, indent=4) + """ + def testInquireJSON(self): + filter = json.loads('{ "QName" : "*" }') + data = self.appJSON('/api/queue/inquire/' + self.qmgr, filter) + self.assertFalse('mqweb' not in data, 'No mqweb data returned') + + if 'error' in data: + self.assertFalse(True, 'Received a WebSphere MQ error:' + str(data['error']['reason']['code'])) + + self.assertFalse('queues' not in data, 'No queues returned') + + self.assertTrue(self.checkIds(data['queues'][0]), 'There are unmapped Websphere MQ attributes') + print json.dumps(data, indent=4) + suite = unittest.TestLoader().loadTestsFromTestCase(TestQueueActions) unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/test/testbase.py b/test/testbase.py index 2efeefe..b5761ab 100644 --- a/test/testbase.py +++ b/test/testbase.py @@ -49,7 +49,21 @@ def getJSON(self, url): conn.request('GET', url, "", MQWebTest.headers) res = conn.getresponse() data = json.loads(res.read()) - except: + except httplib.HTTPException as e: + print 'Exception Caught: ' + e.errno + e.strerror self.assertFalse(True, "Can't connect to MQWeb: " + self.mqWebHost + ":" + self.mqWebPort + ' (qmgr: ' + self.qmgr + ')') - return data \ No newline at end of file + return data + + def appJSON(self, url, filter): + print 'Trying to connect to ' + url + try: + conn = httplib.HTTPConnection(self.mqWebHost, self.mqWebPort) + conn.request('POST', url, json.dumps(filter), MQWebTest.headers) + res = conn.getresponse() + data = json.loads(res.read()) + except httplib.HTTPException as e: + print 'Exception Caught: ' + e.errno + e.strerror + self.assertFalse(True, "Can't connect to MQWeb: " + self.mqWebHost + ":" + self.mqWebPort + ' (qmgr: ' + self.qmgr + ')') + + return data From 1da1a84d25592bb34715743d90ea73c1da14545f Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 14 Aug 2014 18:33:52 +0200 Subject: [PATCH 027/143] Add test scripts --- test/authinfo.py | 20 ++++++++++++++++++++ test/authrec.py | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/authinfo.py create mode 100644 test/authrec.py diff --git a/test/authinfo.py b/test/authinfo.py new file mode 100644 index 0000000..0659bc9 --- /dev/null +++ b/test/authinfo.py @@ -0,0 +1,20 @@ +import unittest +from testbase import MQWebTest + +class TestAuthenticationInformationActions(MQWebTest): + + def testInquire(self): + + data = self.getJSON('/api/authinfo/inquire/' + self.qmgr) + + self.assertFalse('mqweb' not in data, 'No mqweb data returned') + + if 'error' in data: + self.assertFalse(True, 'Received a WebSphere MQ error:' + str(data['error']['reason']['code'])) + + self.assertFalse('authinfos' not in data, 'No authentication information returned') + self.assertFalse(len(data['authinfos']) == 0, 'Empty JSON array returned. Does MQWeb have permission to view this information?') + self.assertTrue(self.checkIds(data['authinfos'][0]), 'There are unmapped Websphere MQ attributes') + +suite = unittest.TestLoader().loadTestsFromTestCase(TestAuthenticationInformationActions) +unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/test/authrec.py b/test/authrec.py new file mode 100644 index 0000000..add3f16 --- /dev/null +++ b/test/authrec.py @@ -0,0 +1,20 @@ +import unittest +from testbase import MQWebTest + +class TestAuthorityRecordActions(MQWebTest): + + def testInquire(self): + + data = self.getJSON('/api/authrec/inquire/' + self.qmgr + '?options=Name%20All%20Matching&options=Entity%20Explicit') + + self.assertFalse('mqweb' not in data, 'No mqweb data returned') + + if 'error' in data: + self.assertFalse(True, 'Received a WebSphere MQ error:' + str(data['error']['reason']['code'])) + + self.assertFalse('authrecs' not in data, 'No authority records returned') + self.assertFalse(len(data['authrecs']) == 0, 'Empty JSON array returned. Does MQWeb have permission to view this information?') + self.assertTrue(self.checkIds(data['authrecs'][0]), 'There are unmapped Websphere MQ attributes') + +suite = unittest.TestLoader().loadTestsFromTestCase(TestAuthorityRecordActions) +unittest.TextTestRunner(verbosity=2).run(suite) From 479fea3400b032551d040da636bfbca74c00987a Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 14 Aug 2014 18:34:00 +0200 Subject: [PATCH 028/143] Add Perl sample --- samples/queue.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 samples/queue.pl diff --git a/samples/queue.pl b/samples/queue.pl new file mode 100644 index 0000000..cc931e3 --- /dev/null +++ b/samples/queue.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl +use strict; +use warnings; +use LWP::UserAgent; +use HTTP::Request::Common; + + +my $json = '{ "QName" : "T*" }'; + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/queue/inquire/EAGLE'; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json); + +my $res = $ua->request($req); + +print $res->content(); \ No newline at end of file From e1b14b169e3b80f2b83e3078dee65210846714bb Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 25 Aug 2014 21:24:26 +0200 Subject: [PATCH 029/143] Allow QAttrs and Attrs query parameters for selecting attributes --- MQWeb/src/QueueController.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index 95f0cff..6949842 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -53,8 +53,8 @@ void QueueController::inquire() std::vector parameters = getParameters(); // First parameter is queuemanager - // Second parameter can be a queuename and will result in inquiring - // only that queue and ignores all query parameters. + // Second parameter can be a queuename. If this is passed, the + // query parameter QName or queueName is ignored. if ( parameters.size() > 1 ) { pcfParameters->set("QName", parameters[1]); @@ -116,7 +116,13 @@ void QueueController::inquire() Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); pcfParameters->set("QAttrs", attrs); - for(Poco::Net::NameValueCollection::ConstIterator itAttrs = form().find("Attrs"); + Poco::Net::NameValueCollection::ConstIterator itAttrs = form().find("QAttrs"); + if ( itAttrs == form().end() ) + { + itAttrs = form().find("Attrs"); + } + + for(; itAttrs != form().end() && Poco::icompare(itAttrs->first, "Attrs") == 0; ++itAttrs) { From 497aed6bb03bb6eff968e6a791fd5eacd4e8b4f5 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 25 Aug 2014 21:24:57 +0200 Subject: [PATCH 030/143] Make it possible to use JSON POST --- MQWeb/src/ChannelController.cpp | 71 +++++++++++++++++++++++---------- MQWeb/src/ChannelMapper.cpp | 25 +++++++++--- 2 files changed, 69 insertions(+), 27 deletions(-) diff --git a/MQWeb/src/ChannelController.cpp b/MQWeb/src/ChannelController.cpp index 8b65b96..abd0445 100644 --- a/MQWeb/src/ChannelController.cpp +++ b/MQWeb/src/ChannelController.cpp @@ -40,37 +40,64 @@ ChannelController::~ChannelController() void ChannelController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); - - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a channelname and will result in inquiring - // only that channel. A third parameter is required because we need - // also the type of the channel for inquiring a specific channel. - if ( parameters.size() > 1 ) + Poco::JSON::Object::Ptr pcfParameters; + + if ( data().has("filter") && data().isObject("filter") ) + { + pcfParameters = data().getObject("filter"); + } + else { - filter->set("name", parameters[1]); + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a channelname. If this is passed + // the query parameter ChannelName is ignored. A third parameter + // can be used for setting the channel type. This parameter can also + // be set using the query parameter ChannelType. + if ( parameters.size() > 1 ) + { + pcfParameters->set("ChannelName", parameters[1]); + } + else + { + std::string channelNameField = form().get("ChannelName", "*"); + pcfParameters->set("ChannelName", channelNameField.empty() ? "*" : channelNameField); + } + if ( parameters.size() > 2 ) { - filter->set("type", parameters[2]); + pcfParameters->set("ChannelType", parameters[2]); } else { - setResponseStatus(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST, "ChannelType is required when channelname is part of the URI-path"); - return; + pcfParameters->set("ChannelType", form().get("ChannelType", "All")); + } + + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + pcfParameters->set("ChannelAttrs", attrs); + + Poco::Net::NameValueCollection::ConstIterator itAttrs = form().find("ChannelAttrs"); + if ( itAttrs == form().end() ) + { + itAttrs = form().find("Attrs"); + } + + for(; + itAttrs != form().end() && Poco::icompare(itAttrs->first, "Attrs") == 0; + ++itAttrs) + { + attrs->add(itAttrs->second); } - } - else - { - std::string channelNameField = form().get("channelName", "*"); - filter->set("name", channelNameField.empty() ? "*" : channelNameField); - filter->set("type", form().get("channelType", "All")); - filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); } - ChannelMapper channelMapper(*commandServer()); - Poco::JSON::Array::Ptr jsonChannels = channelMapper.inquire(filter); - set("channels", jsonChannels); + ChannelMapper mapper(*commandServer()); + Poco::JSON::Array::Ptr channels = mapper.inquire(pcfParameters); + set("channels", channels); setView(new JSONView()); } diff --git a/MQWeb/src/ChannelMapper.cpp b/MQWeb/src/ChannelMapper.cpp index f7ad6d7..e23c271 100644 --- a/MQWeb/src/ChannelMapper.cpp +++ b/MQWeb/src/ChannelMapper.cpp @@ -21,8 +21,6 @@ #include "MQ/Web/ChannelMapper.h" #include "MQ/MQException.h" -#include "Poco/JSON/Object.h" - namespace MQ { namespace Web { @@ -61,10 +59,12 @@ Poco::JSON::Array::Ptr ChannelMapper::inquire(const Poco::JSON::Object::Ptr& fil Poco::JSON::Array::Ptr channels = new Poco::JSON::Array(); PCF::Ptr inquireChl = _commandServer.createCommand(MQCMD_INQUIRE_CHANNEL); + inquireChl->addParameter(MQCACH_CHANNEL_NAME, filter->optValue("ChannelName", "*")); - inquireChl->addParameter(MQCACH_CHANNEL_NAME, filter->optValue("name", "*")); + handleIntegerFilter(inquireChl, filter); + handleStringFilter(inquireChl, filter); - std::string channelType = filter->optValue("type", "All"); + std::string channelType = filter->optValue("ChannelType", "All"); MQLONG channelTypeValue = dictionary()->getDisplayId(MQIACH_CHANNEL_TYPE, channelType); poco_assert_dbg(channelTypeValue != -1); if ( channelTypeValue == - 1 ) @@ -73,10 +73,25 @@ Poco::JSON::Array::Ptr ChannelMapper::inquire(const Poco::JSON::Object::Ptr& fil } inquireChl->addParameter(MQIACH_CHANNEL_TYPE, channelTypeValue); + if ( filter->has("ChannelAttrs") ) + { + Poco::JSON::Array::Ptr attrs = filter->getArray("ChannelAttrs"); + if ( !attrs.isNull() && attrs->size() > 0 ) + { + std::vector numList; + for(Poco::JSON::Array::ValueVec::const_iterator it = attrs->begin(); it != attrs->end(); ++it) + { + MQLONG id = dictionary()->getId(*it); + if ( id != -1 ) numList.push_back(id); + } + if ( numList.size() > 0 ) inquireQ->addParameterList(MQIACF_Q_ATTRS, numList); + } + } + PCF::Vector commandResponse; _commandServer.sendCommand(inquireChl, commandResponse); - bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeSystem = filter->optValue("ExcludeSystem", false); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { From 8c710495aa6eb27f3d0717c0686fc027c1f66d02 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Tue, 26 Aug 2014 13:02:42 +0200 Subject: [PATCH 031/143] Solve undefined inquireQ variable --- MQWeb/src/ChannelMapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQWeb/src/ChannelMapper.cpp b/MQWeb/src/ChannelMapper.cpp index e23c271..c9eba1b 100644 --- a/MQWeb/src/ChannelMapper.cpp +++ b/MQWeb/src/ChannelMapper.cpp @@ -84,7 +84,7 @@ Poco::JSON::Array::Ptr ChannelMapper::inquire(const Poco::JSON::Object::Ptr& fil MQLONG id = dictionary()->getId(*it); if ( id != -1 ) numList.push_back(id); } - if ( numList.size() > 0 ) inquireQ->addParameterList(MQIACF_Q_ATTRS, numList); + if ( numList.size() > 0 ) inquireChl->addParameterList(MQIACF_Q_ATTRS, numList); } } From 11a57eac53f19db03752f38694b08664a2d12506 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 26 Aug 2014 18:50:15 +0200 Subject: [PATCH 032/143] Add handleAttrs function --- MQWeb/include/MQ/Web/MQMapper.h | 3 +++ MQWeb/src/MQMapper.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/MQWeb/include/MQ/Web/MQMapper.h b/MQWeb/include/MQ/Web/MQMapper.h index 8c46c23..433ed5f 100644 --- a/MQWeb/include/MQ/Web/MQMapper.h +++ b/MQWeb/include/MQ/Web/MQMapper.h @@ -57,6 +57,9 @@ class MQMapper : public Mapper static const Poco::SharedPtr dictionary(const std::string& objectType); /// Returns the dictionary for the given object type + void handleAttrs(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter, const std::string& attr, MQLONG attrId); + /// Handles the attribute list + void handleIntegerFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter); /// When IntegerFilterCommand is set, it will add an integer filter to the PCF message diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index 3ac20f0..2c528cd 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -142,4 +142,22 @@ void MQMapper::handleStringFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter) } } +void MQMapper::handleAttrs(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter, const std::string& attr, MQLONG attrId) +{ + if ( filter->has(attr) ) + { + Poco::JSON::Array::Ptr attrs = filter->getArray(attr); + if ( !attrs.isNull() && attrs->size() > 0 ) + { + std::vector numList; + for(Poco::JSON::Array::ValueVec::const_iterator it = attrs->begin(); it != attrs->end(); ++it) + { + MQLONG id = dictionary()->getId(*it); + if ( id != -1 ) numList.push_back(id); + } + if ( numList.size() > 0 ) pcf->addParameterList(attrId, numList); + } + } +} + }} // Namespace MQ::Web From cd3a23d1cee255e2daf54c24c51792f5f55cfdc4 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 26 Aug 2014 18:50:53 +0200 Subject: [PATCH 033/143] Allow QType and QueueType as query parameter --- MQWeb/src/QueueController.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index 6949842..8855ebf 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -109,7 +109,20 @@ void QueueController::inquire() pcfParameters->set("Usage", form().get("Usage")); } - pcfParameters->set("QType", form().get("queueType", "All")); + std::string queueType; + if ( form().has("queueType") ) + { + queueType = form().get("queueType"); + } + else + { + queueType = form().get("QType", ""); + } + if ( !queueType.empty() ) + { + pcfParameters->set("QType", form().get("queueType", "All")); + } + pcfParameters->set("ExcludeSystem", form().get("excludeSystem", "false").compare("true") == 0); pcfParameters->set("ExcludeTemp", form().get("excludeTemp", "false").compare("true") == 0); From d5fcdcb68cae8d80d181d111d754ccf4e50a289b Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 26 Aug 2014 18:51:19 +0200 Subject: [PATCH 034/143] Use handleAttr --- MQWeb/src/ChannelMapper.cpp | 15 +-------------- MQWeb/src/QueueMapper.cpp | 15 +-------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/MQWeb/src/ChannelMapper.cpp b/MQWeb/src/ChannelMapper.cpp index e23c271..5ac3d23 100644 --- a/MQWeb/src/ChannelMapper.cpp +++ b/MQWeb/src/ChannelMapper.cpp @@ -73,20 +73,7 @@ Poco::JSON::Array::Ptr ChannelMapper::inquire(const Poco::JSON::Object::Ptr& fil } inquireChl->addParameter(MQIACH_CHANNEL_TYPE, channelTypeValue); - if ( filter->has("ChannelAttrs") ) - { - Poco::JSON::Array::Ptr attrs = filter->getArray("ChannelAttrs"); - if ( !attrs.isNull() && attrs->size() > 0 ) - { - std::vector numList; - for(Poco::JSON::Array::ValueVec::const_iterator it = attrs->begin(); it != attrs->end(); ++it) - { - MQLONG id = dictionary()->getId(*it); - if ( id != -1 ) numList.push_back(id); - } - if ( numList.size() > 0 ) inquireQ->addParameterList(MQIACF_Q_ATTRS, numList); - } - } + handleAttrs(inquireChl, filter, "ChannelAttrs", MQIACF_CHANNEL_ATTRS); PCF::Vector commandResponse; _commandServer.sendCommand(inquireChl, commandResponse); diff --git a/MQWeb/src/QueueMapper.cpp b/MQWeb/src/QueueMapper.cpp index f42be7e..06772c4 100644 --- a/MQWeb/src/QueueMapper.cpp +++ b/MQWeb/src/QueueMapper.cpp @@ -88,20 +88,7 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte } inquireQ->addParameter(MQIA_Q_TYPE, queueTypeValue); - if ( filter->has("QAttrs") ) - { - Poco::JSON::Array::Ptr attrs = filter->getArray("QAttrs"); - if ( !attrs.isNull() && attrs->size() > 0 ) - { - std::vector numList; - for(Poco::JSON::Array::ValueVec::const_iterator it = attrs->begin(); it != attrs->end(); ++it) - { - MQLONG id = dictionary()->getId(*it); - if ( id != -1 ) numList.push_back(id); - } - if ( numList.size() > 0 ) inquireQ->addParameterList(MQIACF_Q_ATTRS, numList); - } - } + handleAttrs(inquireQ, filter, "QAttrs", MQIACF_Q_ATTRS); PCF::Vector commandResponse; _commandServer.sendCommand(inquireQ, commandResponse); From 4614c0c8c1ecdfd2041ce5467851fb16d9bf941b Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 29 Aug 2014 19:05:41 +0200 Subject: [PATCH 035/143] Add formElementToJSONArray --- MQWeb/include/MQ/Web/Controller.h | 3 +++ MQWeb/src/Controller.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/MQWeb/include/MQ/Web/Controller.h b/MQWeb/include/MQ/Web/Controller.h index 22fea53..cd48096 100644 --- a/MQWeb/include/MQ/Web/Controller.h +++ b/MQWeb/include/MQ/Web/Controller.h @@ -71,6 +71,9 @@ class Controller : public Poco::Net::PartHandler /// Called after an action is executed. The default implementation renders /// the associated view. When no view is set, a JSON view will be used + void formElementToJSONArray(const std::string& name, Poco::JSON::Array::Ptr arr); + /// Stores each element with the given name in a JSON array + virtual const ActionMap& getActions() const = 0; /// Returns all actions. diff --git a/MQWeb/src/Controller.cpp b/MQWeb/src/Controller.cpp index 835e43f..d0264aa 100644 --- a/MQWeb/src/Controller.cpp +++ b/MQWeb/src/Controller.cpp @@ -181,6 +181,15 @@ void Controller::render() } } +void Controller::formElementToJSONArray(const std::string& name, Poco::JSON::Array::Ptr arr) +{ + for(Poco::Net::NameValueCollection::ConstIterator it = form().find(name); + it != form().end() && Poco::icompare(it->first, name) == 0; + ++it) + { + arr->add(it->second); + } +} std::string Controller::htmlize(const std::string &str) { From 67a6002bf5e84abdb48cbaf04412aac9df878829 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 29 Aug 2014 19:06:37 +0200 Subject: [PATCH 036/143] add handleFilterForm --- MQWeb/include/MQ/Web/MQController.h | 4 ++++ MQWeb/src/MQController.cpp | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/MQWeb/include/MQ/Web/MQController.h b/MQWeb/include/MQ/Web/MQController.h index 8f4ef55..0161e9f 100644 --- a/MQWeb/include/MQ/Web/MQController.h +++ b/MQWeb/include/MQ/Web/MQController.h @@ -59,6 +59,10 @@ class MQController : public Controller void afterAction(); /// Stops the stopwatch and calls Controller::afterAction + void handleFilterForm(Poco::JSON::Object::Ptr pcfParameters); + /// Creates an IntegerFilterCommand or StringFilterCommand + /// when a filter is passed. + Poco::JSON::Object& mqwebData(); /// Returns the JSON object for storing MQWeb data. /// This object can be used to store common data like queuemanager name, diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index cdd6720..e28446c 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -212,5 +212,25 @@ void MQController::handle(const std::vector& parameters, Poco::Net: } } +void MQController::handleFilterForm(Poco::JSON::Object::Ptr pcfParameters) +{ + if ( form().has("Filter") && form().has("FilterParam") && form().has("FilterValue") ) + { + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + filter->set("Parameter", form().get("FilterParam")); + filter->set("Operator", form().get("FilterOp", "EQ")); + filter->set("FilterValue", form().get("FilterVlue")); + + std::string filterType = form().get("Filter"); + if ( Poco::icompare(filterType, "I") == 0 ) + { + pcfParameters->set("IntegerFilterCommand", filter); + } + else if ( Poco::icompare(filterType, "S") == 0 ) + { + pcfParameters->set("StringFilterCommand", filter); + } + } +} }} // namespace MQ::Web From 65835340f2d49ed9cadeba053a02fecd65dba794 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 29 Aug 2014 19:07:23 +0200 Subject: [PATCH 037/143] Add innerclass Command in MQMapper and make use of it --- MQWeb/include/MQ/Web/MQMapper.h | 80 +++++++++-- .../AuthenticationInformationController.cpp | 74 +++++++++-- MQWeb/src/AuthenticationInformationMapper.cpp | 20 ++- MQWeb/src/AuthorityRecordMapper.cpp | 49 +++---- MQWeb/src/ChannelMapper.cpp | 31 ++--- MQWeb/src/ChannelStatusMapper.cpp | 35 ++--- MQWeb/src/ClusterQueueManagerMapper.cpp | 29 ++-- MQWeb/src/ConnectionMapper.cpp | 25 ++-- MQWeb/src/ListenerMapper.cpp | 25 ++-- MQWeb/src/ListenerStatusMapper.cpp | 15 ++- MQWeb/src/MQMapper.cpp | 125 +++++++++++------- MQWeb/src/NamelistMapper.cpp | 17 ++- MQWeb/src/ProcessMapper.cpp | 17 ++- MQWeb/src/QueueController.cpp | 4 +- MQWeb/src/QueueManagerMapper.cpp | 8 +- MQWeb/src/QueueManagerStatusMapper.cpp | 39 +++--- MQWeb/src/QueueMapper.cpp | 37 +++--- MQWeb/src/QueueStatusMapper.cpp | 37 +++--- MQWeb/src/ServiceMapper.cpp | 15 ++- 19 files changed, 415 insertions(+), 267 deletions(-) diff --git a/MQWeb/include/MQ/Web/MQMapper.h b/MQWeb/include/MQ/Web/MQMapper.h index 433ed5f..97f403b 100644 --- a/MQWeb/include/MQ/Web/MQMapper.h +++ b/MQWeb/include/MQ/Web/MQMapper.h @@ -42,6 +42,9 @@ class MQMapper : public Mapper virtual ~MQMapper(); /// Destructor + const CommandServer& commandServer() const; + /// Returns the associated commandserver + const Poco::SharedPtr dictionary() const; /// Returns the dictionary for the associated object type @@ -57,18 +60,47 @@ class MQMapper : public Mapper static const Poco::SharedPtr dictionary(const std::string& objectType); /// Returns the dictionary for the given object type - void handleAttrs(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter, const std::string& attr, MQLONG attrId); - /// Handles the attribute list +protected: + + class Command + { + public: + Command(MQMapper* mapper, MQLONG command, Poco::JSON::Object::Ptr filter); - void handleIntegerFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter); - /// When IntegerFilterCommand is set, it will add an integer filter to the PCF message + virtual ~Command(); - void handleStringFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter); - /// When StringFilterCommand is set, it will add an string filter to the PCF message + void addAttributeList(MQLONG attrId, const std::string& attr); + /// Handles the attribute list -protected: + void addIntegerFilter(); + /// When IntegerFilterCommand is set, it will add an integer filter to the PCF message + + template + void addParameter(MQLONG parameter, const std::string& name); + + void addParameterNumFromString(MQLONG parameter, const std::string& name); + + void addStringFilter(); + /// When StringFilterCommand is set, it will add an string filter to the PCF message + + void execute(PCF::Vector& response); + /// Sends the PCF command to the command server + + PCF::Ptr pcf(); + /// Returns the PCF command message + + private: + + MQMapper* _mapper; + + PCF::Ptr _pcf; + + Poco::JSON::Object::Ptr _filter; + }; - MQ::CommandServer& _commandServer; +private: + + CommandServer& _commandServer; Poco::SharedPtr _dictionary; @@ -77,6 +109,27 @@ class MQMapper : public Mapper static DictionaryCache _dictionaryCache; }; +template +inline void MQMapper::Command::addParameter(MQLONG parameter, const std::string& name) +{ + Poco::Dynamic::Var value = _filter->get(name); + if (! value.isEmpty() ) + { + try + { + _pcf->addParameter(parameter, value.convert()); + } + catch(...) + { + poco_assert_dbg(false); + } + } +} + +inline const CommandServer& MQMapper::commandServer() const +{ + return _commandServer; +} inline const Poco::SharedPtr MQMapper::dictionary() const { @@ -88,6 +141,17 @@ inline const Poco::SharedPtr MQMapper::dictionary(const std::string& return _dictionaryCache.getDictionary(objectType); } +inline void MQMapper::Command::execute(PCF::Vector& response) +{ + poco_check_ptr(_pcf); + _mapper->_commandServer.sendCommand(_pcf, response); +} + +inline PCF::Ptr MQMapper::Command::pcf() +{ + return _pcf; +} + }} // Namespace MQ::Web #endif // _MQWeb_MQMapper_H diff --git a/MQWeb/src/AuthenticationInformationController.cpp b/MQWeb/src/AuthenticationInformationController.cpp index 522934d..d0c38a7 100644 --- a/MQWeb/src/AuthenticationInformationController.cpp +++ b/MQWeb/src/AuthenticationInformationController.cpp @@ -40,31 +40,77 @@ AuthenticationInformationController::~AuthenticationInformationController() void AuthenticationInformationController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a authentication information name and will result in inquiring - // only that queue and ignores all query parameters. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("authInfoName", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - // Handle query parameters - std::string authInfoNameField = form().get("authInfoName", "*"); - if ( authInfoNameField.empty() ) + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a authentication information name (generic name is allowed) + if ( parameters.size() > 1 ) + { + pcfParameters->set("AuthInfoName", parameters[1]); + } + else + { + // Handle query parameters + std::string authInfoNameField; + if ( form().has("AuthInfoName") ) + { + authInfoNameField = form().get("AuthInfoName"); + } + else if ( form().has("name") ) + { + authInfoNameField = form().get("name"); + } + if ( authInfoNameField.empty() ) + { + authInfoNameField = "*"; + } + pcfParameters->set("AuthInfoName", authInfoNameField); + } + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + pcfParameters->set("AuthInfoAttrs", attrs); + formElementToJSONArray("AuthInfoAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for AuthInfoAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("AuthInfoAttrs", attrs); + } + + if ( form().has("AuthInfoType") ) + { + pcfParameters->set("AuthInfoType", form().get("AuthInfoType")); + } + + if ( form().has("CommandScope") ) { - authInfoNameField = "*"; + pcfParameters->set("CommandScope", form().get("CommandScope")); } - filter->set("authInfoName", authInfoNameField); - filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + if ( form().has("QSGDisposition") ) + { + pcfParameters->set("QSGDisposition", form().get("QSGDisposition")); + } + + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + + handleFilterForm(pcfParameters); } AuthenticationInformationMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(filter); + Poco::JSON::Array::Ptr json = mapper.inquire(pcfParameters); set("authinfos", json); } diff --git a/MQWeb/src/AuthenticationInformationMapper.cpp b/MQWeb/src/AuthenticationInformationMapper.cpp index 2b093c2..0bbb587 100644 --- a/MQWeb/src/AuthenticationInformationMapper.cpp +++ b/MQWeb/src/AuthenticationInformationMapper.cpp @@ -55,16 +55,26 @@ void AuthenticationInformationMapper::copy(const Poco::JSON::Object::Ptr& obj, b Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire(const Poco::JSON::Object::Ptr& filter) { poco_assert_dbg(!filter.isNull()); + + Command command(this, MQCMD_INQUIRE_AUTH_INFO, filter); - Poco::JSON::Array::Ptr jsonAuthInfos = new Poco::JSON::Array(); + // Required parameters + command.addParameter(MQCA_AUTH_INFO_NAME, "AuthInfoName"); - PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_AUTH_INFO); - command->addParameter(MQCA_AUTH_INFO_NAME, filter->optValue("authInfoName", "*")); + // Optional parameters + command.addAttributeList(MQIACF_AUTH_INFO_ATTRS, "AuthInfoAttrs"); + command.addParameterNumFromString(MQIA_AUTH_INFO_TYPE, "AuthInfoType"); + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addIntegerFilter(); + command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + command.addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(command, commandResponse); + command.execute(commandResponse); + + bool excludeSystem = filter->optValue("ExcludeSystem", false); - bool excludeSystem = filter->optValue("excludeSystem", false); + Poco::JSON::Array::Ptr jsonAuthInfos = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { diff --git a/MQWeb/src/AuthorityRecordMapper.cpp b/MQWeb/src/AuthorityRecordMapper.cpp index 16085ab..5e86fa9 100644 --- a/MQWeb/src/AuthorityRecordMapper.cpp +++ b/MQWeb/src/AuthorityRecordMapper.cpp @@ -54,14 +54,13 @@ Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire(const Poco::JSON::Object:: { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); + Command command(this, MQCMD_INQUIRE_AUTH_RECS, filter); + + // Required parameters + command.addParameter(MQCACF_AUTH_PROFILE_NAME, "ProfileName"); - PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_AUTH_RECS); - - if ( filter->has("profileName") ) command->addParameter(MQCACF_AUTH_PROFILE_NAME, filter->optValue("profileName", "*")); - MQLONG options = 0; - Poco::JSON::Array::Ptr optionsValue = filter->getArray("options"); + Poco::JSON::Array::Ptr optionsValue = filter->getArray("Options"); if ( !optionsValue.isNull() ) { for(Poco::JSON::Array::ValueVec::const_iterator it = optionsValue->begin(); it != optionsValue->end(); ++it) @@ -89,38 +88,20 @@ Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire(const Poco::JSON::Object:: } } } - command->addParameter(MQIACF_AUTH_OPTIONS, options); + command.pcf()->addParameter(MQIACF_AUTH_OPTIONS, options); - std::string objectType = filter->optValue("objectType", "All"); - MQLONG objectTypeValue = dictionary()->getDisplayId(MQIACF_OBJECT_TYPE, objectType); - poco_assert_dbg(objectTypeValue != -1); - if ( objectTypeValue == - 1 ) - { - return json; - } - command->addParameter(MQIACF_OBJECT_TYPE, objectTypeValue); + command.addParameterNumFromString(MQIACF_OBJECT_TYPE, "ObjectType"); - if ( filter->has("entityName") ) command->addParameter(MQCACF_ENTITY_NAME, filter->optValue("entityName", "")); - - if ( filter->has("entityType") ) - { - std::string entityType = filter->optValue("entityType", ""); - if ( !entityType.empty() ) - { - MQLONG entityTypeValue = dictionary()->getDisplayId(MQIACF_ENTITY_TYPE, entityType); - poco_assert_dbg(entityTypeValue != -1); - if ( entityTypeValue == - 1 ) - { - return json; - } - command->addParameter(MQIACF_ENTITY_TYPE, entityTypeValue); - } - } - - if ( filter->has("serviceComponent") ) command->addParameter(MQCACF_SERVICE_COMPONENT, filter->optValue("serviceComponent", "")); + // Optional parameters + command.addParameter(MQCACF_ENTITY_NAME, "EntityName"); + command.addParameterNumFromString(MQIACF_ENTITY_TYPE, "EntityType"); + command.addAttributeList(MQIACF_AUTH_PROFILE_ATTRS, "ProfileAttrs"); + command.addParameter(MQCACF_SERVICE_COMPONENT, "ServiceComponent"); PCF::Vector commandResponse; - _commandServer.sendCommand(command, commandResponse); + command.execute(commandResponse); + + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { diff --git a/MQWeb/src/ChannelMapper.cpp b/MQWeb/src/ChannelMapper.cpp index 5ac3d23..71d492c 100644 --- a/MQWeb/src/ChannelMapper.cpp +++ b/MQWeb/src/ChannelMapper.cpp @@ -56,30 +56,27 @@ Poco::JSON::Array::Ptr ChannelMapper::inquire(const Poco::JSON::Object::Ptr& fil { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr channels = new Poco::JSON::Array(); - - PCF::Ptr inquireChl = _commandServer.createCommand(MQCMD_INQUIRE_CHANNEL); - inquireChl->addParameter(MQCACH_CHANNEL_NAME, filter->optValue("ChannelName", "*")); + Command command(this, MQCMD_INQUIRE_CHANNEL, filter); - handleIntegerFilter(inquireChl, filter); - handleStringFilter(inquireChl, filter); + // Required Parameters + command.addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); - std::string channelType = filter->optValue("ChannelType", "All"); - MQLONG channelTypeValue = dictionary()->getDisplayId(MQIACH_CHANNEL_TYPE, channelType); - poco_assert_dbg(channelTypeValue != -1); - if ( channelTypeValue == - 1 ) - { - return channels; - } - inquireChl->addParameter(MQIACH_CHANNEL_TYPE, channelTypeValue); - - handleAttrs(inquireChl, filter, "ChannelAttrs", MQIACF_CHANNEL_ATTRS); + // Optional Parameters + command.addAttributeList(MQIACF_CHANNEL_ATTRS, "ChannelAttrs"); + command.addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addParameterNumFromString(MQIACH_CHANNEL_DISP, "DefaultChannelDisposition"); + command.addIntegerFilter(); + command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + command.addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireChl, commandResponse); + command.execute(commandResponse); bool excludeSystem = filter->optValue("ExcludeSystem", false); + Poco::JSON::Array::Ptr channels = new Poco::JSON::Array(); + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) diff --git a/MQWeb/src/ChannelStatusMapper.cpp b/MQWeb/src/ChannelStatusMapper.cpp index 453aa06..7764821 100644 --- a/MQWeb/src/ChannelStatusMapper.cpp +++ b/MQWeb/src/ChannelStatusMapper.cpp @@ -58,12 +58,13 @@ Poco::JSON::Array::Ptr ChannelStatusMapper::inquire(const Poco::JSON::Object::Pt { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr jsonStatuses = new Poco::JSON::Array(); - - PCF::Ptr inquireChlStatus = _commandServer.createCommand(MQCMD_INQUIRE_CHANNEL_STATUS); + Command command(this, MQCMD_INQUIRE_CHANNEL_STATUS, filter); - inquireChlStatus->addParameter(MQCACH_CHANNEL_NAME, filter->optValue("name", "*")); + // Required parameters + command.addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); + /*TODO: move to controller! + command.addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); if ( filter->has("type") ) { std::string channelType = filter->optValue("type", "All"); @@ -73,19 +74,23 @@ Poco::JSON::Array::Ptr ChannelStatusMapper::inquire(const Poco::JSON::Object::Pt { inquireChlStatus->addFilter(MQIACH_CHANNEL_TYPE, MQCFOP_EQUAL, channelTypeValue); } - } - - MQLONG instanceTypeValue = MQOT_CURRENT_CHANNEL; - if ( filter->has("instanceType") ) - { - std::string instanceType = filter->optValue("type", "Current"); - instanceTypeValue = dictionary()->getDisplayId(MQIACH_CHANNEL_INSTANCE_TYPE, instanceType); - poco_assert_dbg(instanceTypeValue != -1); - } - inquireChlStatus->addParameter(MQIACH_CHANNEL_INSTANCE_TYPE, instanceTypeValue); + }*/ + + // Optional parameters + command.addParameterNumFromString(MQIACH_CHANNEL_DISP, "ChannelDisposition"); + command.addParameter(MQCACH_CLIENT_ID, "ClientIdentifier"); + command.addAttributeList(MQIACH_CHANNEL_INSTANCE_ATTRS, "ChannelInstanceAttrs"); + command.addParameterNumFromString(MQIACH_CHANNEL_INSTANCE_TYPE, "ChannelInstanceType"); + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addParameter(MQCACH_CONNECTION_NAME, "ConnectionName"); + command.addIntegerFilter(); + command.addStringFilter(); + command.addParameter(MQCACH_XMIT_Q_NAME, "XmitQName"); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireChlStatus, commandResponse); + command.execute(commandResponse); + + Poco::JSON::Array::Ptr jsonStatuses = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { diff --git a/MQWeb/src/ClusterQueueManagerMapper.cpp b/MQWeb/src/ClusterQueueManagerMapper.cpp index 27ac530..b28404a 100644 --- a/MQWeb/src/ClusterQueueManagerMapper.cpp +++ b/MQWeb/src/ClusterQueueManagerMapper.cpp @@ -58,28 +58,23 @@ Poco::JSON::Array::Ptr ClusterQueueManagerMapper::inquire(const Poco::JSON::Obje { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr clusqmgrs = new Poco::JSON::Array(); - - PCF::Ptr inquireClusterQMgr = _commandServer.createCommand(MQCMD_INQUIRE_CLUSTER_Q_MGR); - - if ( filter->has("clusterName") ) - { - inquireClusterQMgr->addParameter(MQCA_CLUSTER_NAME, filter->optValue("name", "*")); - } + Command command(this, MQCMD_INQUIRE_CLUSTER_Q_MGR, filter); - if ( filter->has("channelName") ) - { - inquireClusterQMgr->addParameter(MQCACH_CHANNEL_NAME, filter->optValue("channelName", "*")); - } + // Required parameters + command.addParameter(MQCA_CLUSTER_Q_MGR_NAME, "ClusterQmgrName"); - if ( filter->has("clusterQmgrName") ) - { - inquireClusterQMgr->addParameter(MQCA_CLUSTER_Q_MGR_NAME, filter->optValue("clusterQmgrName", "*")); - } + // Optional parameters + command.addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); + command.addParameter(MQCA_CLUSTER_NAME, "ClusterName"); + command.addAttributeList(MQIACF_CLUSTER_Q_MGR_ATTRS, "ClusterQMgrAttrs"); + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addIntegerFilter(); + command.addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireClusterQMgr, commandResponse); + command.execute(commandResponse); + Poco::JSON::Array::Ptr clusqmgrs = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) diff --git a/MQWeb/src/ConnectionMapper.cpp b/MQWeb/src/ConnectionMapper.cpp index 57f1fc9..d9ece8b 100644 --- a/MQWeb/src/ConnectionMapper.cpp +++ b/MQWeb/src/ConnectionMapper.cpp @@ -59,13 +59,12 @@ Poco::JSON::Array::Ptr ConnectionMapper::inquire(const Poco::JSON::Object::Ptr& { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr connections = new Poco::JSON::Array(); - - PCF::Ptr inquireConnections = _commandServer.createCommand(MQCMD_INQUIRE_CONNECTION); + Command command(this, MQCMD_INQUIRE_CONNECTION, filter); - if ( filter->has("id") ) + // Required parameters + if ( filter->has("ConnectionId") ) { - std::string hexId = filter->get("id"); + std::string hexId = filter->get("ConnectionId"); BufferPtr id = new Buffer(hexId.size() / 2); std::istringstream iss(hexId); @@ -78,17 +77,27 @@ Poco::JSON::Array::Ptr ConnectionMapper::inquire(const Poco::JSON::Object::Ptr& c = decoder.get(); } - inquireConnections->addParameter(MQBACF_CONNECTION_ID, id); + command.pcf()->addParameter(MQBACF_CONNECTION_ID, id); } else { BufferPtr id = new Buffer(0); // Empty buffer - inquireConnections->addParameter(MQBACF_GENERIC_CONNECTION_ID, id); + command.pcf()->addParameter(MQBACF_GENERIC_CONNECTION_ID, id); } + // Optional parameters + //TODO: ByteStringFilter + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addAttributeList(MQIACF_CONNECTION_ATTRS, "ConnectionAttrs"); + command.addParameterNumFromString(MQIACF_CONN_INFO_TYPE, "ConnInfoType"); + command.addIntegerFilter(); + command.addStringFilter(); + command.addParameterNumFromString(MQIA_UR_DISP, "URDisposition"); + PCF::Vector commandResponse; - _commandServer.sendCommand(inquireConnections, commandResponse); + command.execute(commandResponse); + Poco::JSON::Array::Ptr connections = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) diff --git a/MQWeb/src/ListenerMapper.cpp b/MQWeb/src/ListenerMapper.cpp index 281b29f..e2bd673 100644 --- a/MQWeb/src/ListenerMapper.cpp +++ b/MQWeb/src/ListenerMapper.cpp @@ -56,26 +56,23 @@ Poco::JSON::Array::Ptr ListenerMapper::inquire(const Poco::JSON::Object::Ptr& fi { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr listeners = new Poco::JSON::Array(); + Command command(this, MQCMD_INQUIRE_LISTENER, filter); - PCF::Ptr inquireListener = _commandServer.createCommand(MQCMD_INQUIRE_LISTENER); - inquireListener->addParameter(MQCACH_LISTENER_NAME, filter->optValue("name", "*")); + // Required parameters + command.addParameter(MQCACH_LISTENER_NAME, "ListenerName"); - std::string listenerType = filter->optValue("type", ""); - if ( !listenerType.empty() ) - { - MQLONG listenerTypeValue = dictionary()->getDisplayId(MQIACH_XMIT_PROTOCOL_TYPE, listenerType); - if ( listenerTypeValue >= -1 && listenerTypeValue <= 6 ) - { - inquireListener->addParameter(MQIACH_XMIT_PROTOCOL_TYPE, listenerTypeValue); - } - } + // Optional parameters + command.addIntegerFilter(); + command.addAttributeList(MQIACF_LISTENER_ATTRS, "ListenerAttrs"); + command.addStringFilter(); + command.addParameterNumFromString(MQIACH_XMIT_PROTOCOL_TYPE, "TransportType"); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireListener, commandResponse); + command.execute(commandResponse); - bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeSystem = filter->optValue("ExcludeSystem", false); + Poco::JSON::Array::Ptr listeners = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->isExtendedResponse() ) // Skip extended response diff --git a/MQWeb/src/ListenerStatusMapper.cpp b/MQWeb/src/ListenerStatusMapper.cpp index 23a11da..2630117 100644 --- a/MQWeb/src/ListenerStatusMapper.cpp +++ b/MQWeb/src/ListenerStatusMapper.cpp @@ -56,13 +56,20 @@ Poco::JSON::Array::Ptr ListenerStatusMapper::inquire(const Poco::JSON::Object::P { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr statuses = new Poco::JSON::Array(); + Command command(this, MQCMD_INQUIRE_LISTENER_STATUS, filter); + + // Required parameters + command.addParameter(MQCACH_LISTENER_NAME, "ListenerName"); - PCF::Ptr inquireListenerStatus = _commandServer.createCommand(MQCMD_INQUIRE_LISTENER_STATUS); - inquireListenerStatus->addParameter(MQCACH_LISTENER_NAME, filter->optValue("name", "*")); + // Optional parameters + command.addIntegerFilter(); + command.addAttributeList(MQIACF_LISTENER_STATUS_ATTRS, "ListenerStatusAttrs"); + command.addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireListenerStatus, commandResponse); + command.execute(commandResponse); + + Poco::JSON::Array::Ptr statuses = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->isExtendedResponse() ) // Skip extended response diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index 2c528cd..24e86e0 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -88,74 +88,101 @@ const DisplayMap& MQMapper::getDisplayMap(const std::string& objectType, MQLONG return dict->getDisplayMap(id); } -void MQMapper::handleIntegerFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter) +MQMapper::Command::Command(MQMapper* mapper, MQLONG command, Poco::JSON::Object::Ptr filter) +: _mapper(mapper) +, _filter(filter) { - if ( filter->has("IntegerFilterCommand") ) + _pcf = _mapper->_commandServer.createCommand(command); +} + +MQMapper::Command::~Command() +{ +} + +void MQMapper::Command::addIntegerFilter() +{ + Poco::JSON::Object::Ptr integerFilter = _filter->getObject("IntegerFilterCommand"); + if ( integerFilter.isNull() ) + return; + + std::string parameterName = integerFilter->optValue("Parameter", ""); + MQLONG parameter = _mapper->dictionary()->getId(parameterName); + if ( parameter == -1 ) + return; + + std::string opString = integerFilter->optValue("Operator", "EQ"); + MQLONG op = getOperator(Poco::toUpper(opString)); + if ( op == -1 ) op = MQCFOP_EQUAL; + + Poco::Dynamic::Var value = integerFilter->get("FilterValue"); + MQLONG filterValue; + if ( value.isString() ) { - Poco::JSON::Object::Ptr integerFilterCommand = filter->getObject("IntegerFilterCommand"); - if ( !integerFilterCommand.isNull() ) - { - std::string parameterName = integerFilterCommand->optValue("Parameter", ""); - MQLONG parameter = dictionary()->getId(parameterName); - if ( parameter != -1 ) - { - std::string opString = integerFilterCommand->optValue("Operator", "EQ"); - MQLONG op = getOperator(Poco::toUpper(opString)); - if ( op == -1 ) op = MQCFOP_EQUAL; - - Poco::Dynamic::Var value = integerFilterCommand->get("FilterValue"); - MQLONG filterValue; - if ( value.isString() ) - { - // A String is passed ... try to find the MQ integer value - filterValue = dictionary()->getDisplayId(parameter, value); - } - else if ( value.isNumeric() ) - { - filterValue = value; - } - pcf->addFilter(parameter, op, filterValue); - } - } + // A String is passed ... try to find the MQ integer value + filterValue = _mapper->dictionary()->getDisplayId(parameter, value); } + else if ( value.isNumeric() ) + { + filterValue = value; + } + _pcf->addFilter(parameter, op, filterValue); } -void MQMapper::handleStringFilter(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter) +void MQMapper::Command::addStringFilter() { - if ( filter->has("StringFilterCommand") ) + Poco::JSON::Object::Ptr stringFilter = _filter->getObject("StringFilterCommand"); + if ( stringFilter.isNull() ) + return; + + std::string parameterName = stringFilter->optValue("Parameter", ""); + MQLONG parameter = _mapper->dictionary()->getId(parameterName); + if ( parameter == -1 ) + return; + + std::string opString = stringFilter->optValue("Operator", "EQ"); + MQLONG op = getOperator(Poco::toUpper(opString)); + if ( op == -1 ) op = MQCFOP_EQUAL; + + std::string filterValue = stringFilter->optValue("FilterValue", ""); + _pcf->addFilter(parameter, op, filterValue); +} + +void MQMapper::Command::addAttributeList(MQLONG attrId, const std::string& attr) +{ + if ( _filter->has(attr) ) { - Poco::JSON::Object::Ptr integerFilterCommand = filter->getObject("StringFilterCommand"); - if ( !integerFilterCommand.isNull() ) + Poco::JSON::Array::Ptr attrs = _filter->getArray(attr); + if ( !attrs.isNull() && attrs->size() > 0 ) { - std::string parameterName = integerFilterCommand->optValue("Parameter", ""); - MQLONG parameter = dictionary()->getId(parameterName); - if ( parameter != -1 ) + std::vector numList; + for(Poco::JSON::Array::ValueVec::const_iterator it = attrs->begin(); it != attrs->end(); ++it) { - std::string opString = integerFilterCommand->optValue("Operator", "EQ"); - MQLONG op = getOperator(Poco::toUpper(opString)); - if ( op == -1 ) op = MQCFOP_EQUAL; - - std::string filterValue = integerFilterCommand->optValue("FilterValue", ""); - pcf->addFilter(parameter, op, filterValue); + MQLONG id = _mapper->dictionary()->getId(*it); + if ( id != -1 ) numList.push_back(id); } + if ( numList.size() > 0 ) _pcf->addParameterList(attrId, numList); } } } -void MQMapper::handleAttrs(PCF::Ptr pcf, Poco::JSON::Object::Ptr filter, const std::string& attr, MQLONG attrId) +void MQMapper::Command::addParameterNumFromString(MQLONG parameter, const std::string& name) { - if ( filter->has(attr) ) + Poco::Dynamic::Var value = _filter->get(name); + if ( ! value.isEmpty() ) { - Poco::JSON::Array::Ptr attrs = filter->getArray(attr); - if ( !attrs.isNull() && attrs->size() > 0 ) + try { - std::vector numList; - for(Poco::JSON::Array::ValueVec::const_iterator it = attrs->begin(); it != attrs->end(); ++it) + std::string stringValue = value.convert(); + MQLONG numValue = _mapper->dictionary()->getDisplayId(parameter, stringValue); + poco_assert_dbg(numValue != -1); + if ( numValue != - 1 ) { - MQLONG id = dictionary()->getId(*it); - if ( id != -1 ) numList.push_back(id); + _pcf->addParameter(parameter, numValue); } - if ( numList.size() > 0 ) pcf->addParameterList(attrId, numList); + } + catch(...) + { + poco_assert_dbg(false); } } } diff --git a/MQWeb/src/NamelistMapper.cpp b/MQWeb/src/NamelistMapper.cpp index 011dfb5..904c9a2 100644 --- a/MQWeb/src/NamelistMapper.cpp +++ b/MQWeb/src/NamelistMapper.cpp @@ -58,17 +58,24 @@ Poco::JSON::Array::Ptr NamelistMapper::inquire(const Poco::JSON::Object::Ptr& fi { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr namelists = new Poco::JSON::Array(); + Command command(this, MQCMD_INQUIRE_NAMELIST, filter); - PCF::Ptr inquireNamelist = _commandServer.createCommand(MQCMD_INQUIRE_NAMELIST); + // Required parameters + command.addParameter(MQCA_NAMELIST_NAME, "NamelistName"); - inquireNamelist->addParameter(MQCA_NAMELIST_NAME, filter->optValue("name", "*")); + // Optional parameters + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addIntegerFilter(); + command.addAttributeList(MQIACF_NAMELIST_ATTRS, "NamelistAttrs"); + command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + command.addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireNamelist, commandResponse); + command.execute(commandResponse); - bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeSystem = filter->optValue("ExcludeSystem", false); + Poco::JSON::Array::Ptr namelists = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) diff --git a/MQWeb/src/ProcessMapper.cpp b/MQWeb/src/ProcessMapper.cpp index 8b214de..b570ced 100644 --- a/MQWeb/src/ProcessMapper.cpp +++ b/MQWeb/src/ProcessMapper.cpp @@ -58,17 +58,24 @@ Poco::JSON::Array::Ptr ProcessMapper::inquire(const Poco::JSON::Object::Ptr& fil { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr processes = new Poco::JSON::Array(); + Command command(this, MQCMD_INQUIRE_PROCESS, filter); - PCF::Ptr inquireProcess = _commandServer.createCommand(MQCMD_INQUIRE_PROCESS); + // Required parameters + command.addParameter(MQCA_PROCESS_NAME, "ProcessName"); - inquireProcess->addParameter(MQCA_PROCESS_NAME, filter->optValue("name", "*")); + // Optional parameters + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addIntegerFilter(); + command.addAttributeList(MQIACF_PROCESS_ATTRS, "ProcessAttrs"); + command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + command.addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireProcess, commandResponse); + command.execute(commandResponse); - bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeSystem = filter->optValue("ExcludeSystem", false); + Poco::JSON::Array::Ptr processes = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index 8855ebf..fe0766d 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -94,12 +94,14 @@ void QueueController::inquire() { Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); filter->set("Parameter", "CurrentQDepth"); - filter->set("Operator", "NLT"); //Not Less + filter->set("Operator", "NLT"); //Not Less## filter->set("FilterValue", queueDepth); pcfParameters->set("IntegerFilterCommand", filter); } } + handleFilterForm(pcfParameters); + if ( form().has("queueUsage") ) { pcfParameters->set("Usage", form().get("queueUsage")); diff --git a/MQWeb/src/QueueManagerMapper.cpp b/MQWeb/src/QueueManagerMapper.cpp index 24752d6..0e6f46e 100644 --- a/MQWeb/src/QueueManagerMapper.cpp +++ b/MQWeb/src/QueueManagerMapper.cpp @@ -58,10 +58,14 @@ Poco::JSON::Array::Ptr QueueManagerMapper::inquire(const Poco::JSON::Object::Ptr { Poco::JSON::Array::Ptr jsonQueueManagers = new Poco::JSON::Array(); - PCF::Ptr inquireQmgr = _commandServer.createCommand(MQCMD_INQUIRE_Q_MGR); + Command command(this, MQCMD_INQUIRE_Q_MGR, filter); + + // Optional parameters + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addAttributeList(MQIACF_Q_MGR_ATTRS, "QMgrAttrs"); std::vector > commandResponse; - _commandServer.sendCommand(inquireQmgr, commandResponse); + command.execute(commandResponse); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { diff --git a/MQWeb/src/QueueManagerStatusMapper.cpp b/MQWeb/src/QueueManagerStatusMapper.cpp index deeed3d..e6d2f09 100644 --- a/MQWeb/src/QueueManagerStatusMapper.cpp +++ b/MQWeb/src/QueueManagerStatusMapper.cpp @@ -56,34 +56,27 @@ void QueueManagerStatusMapper::copy(const Poco::JSON::Object::Ptr& obj, bool rep Poco::JSON::Array::Ptr QueueManagerStatusMapper::inquire(const Poco::JSON::Object::Ptr& filter) { - Poco::JSON::Array::Ptr jsonQueueManagerStatuses = new Poco::JSON::Array(); + Command command(this, MQCMD_INQUIRE_Q_MGR_STATUS, filter); - PCF::Ptr inquireQmgr = _commandServer.createCommand(MQCMD_INQUIRE_Q_MGR_STATUS); + // Optional parameters + command.addAttributeList(MQIACF_Q_MGR_STATUS_ATTRS, "QMStatusAttrs"); std::vector > commandResponse; - _commandServer.sendCommand(inquireQmgr, commandResponse); + command.execute(commandResponse); - if ( commandResponse.size() > 0 ) + Poco::JSON::Array::Ptr jsonQueueManagerStatuses = new Poco::JSON::Array(); + for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { - PCF::Vector::iterator it = commandResponse.begin(); - if ( (*it)->getCompletionCode() != MQCC_OK ) - { - if ( (*it)->getReasonCode() != MQRC_UNKNOWN_OBJECT_NAME ) - { - throw MQException(_commandServer.qmgr().name(), "PCF", (*it)->getCompletionCode(), (*it)->getReasonCode()); - } - } - - for(; it != commandResponse.end(); it++) - { - if ( (*it)->isExtendedResponse() ) // Skip extended response - continue; - - Poco::JSON::Object::Ptr jsonQmgr = new Poco::JSON::Object(); - jsonQueueManagerStatuses->add(jsonQmgr); - - dictionary()->mapToJSON(**it, jsonQmgr); - } + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + Poco::JSON::Object::Ptr jsonQmgr = new Poco::JSON::Object(); + jsonQueueManagerStatuses->add(jsonQmgr); + + dictionary()->mapToJSON(**it, jsonQmgr); } return jsonQueueManagerStatuses; diff --git a/MQWeb/src/QueueMapper.cpp b/MQWeb/src/QueueMapper.cpp index 06772c4..7a02f11 100644 --- a/MQWeb/src/QueueMapper.cpp +++ b/MQWeb/src/QueueMapper.cpp @@ -56,13 +56,22 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr jsonQueues = new Poco::JSON::Array(); - - PCF::Ptr inquireQ = _commandServer.createCommand(MQCMD_INQUIRE_Q); - inquireQ->addParameter(MQCA_Q_NAME, filter->optValue("QName", "*")); - - handleIntegerFilter(inquireQ, filter); - handleStringFilter(inquireQ, filter); + Command command(this, MQCMD_INQUIRE_Q, filter); + + // Required Parameters + command.addParameter(MQCA_Q_NAME, "QName"); + + // Optional Parameters + command.addParameter(MQCA_CF_STRUC_NAME, "CFStructure"); + command.addParameter(MQIACF_CLUSTER_INFO, "ClusterInfo"); + command.addParameter(MQCA_CLUSTER_NAME, "ClusterName"); + command.addParameter(MQCA_CLUSTER_NAMELIST, "ClusterNamelist"); + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addIntegerFilter(); + command.addParameter(MQIA_PAGESET_ID, "PageSetId"); + command.addStringFilter(); + command.addParameterNumFromString(MQIA_Q_TYPE, "QType"); + command.addAttributeList(MQIACF_Q_ATTRS, "QAttrs"); MQLONG usage = -1; if ( filter->has("Usage") ) @@ -79,23 +88,13 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte } } - std::string queueType = filter->optValue("QType", "All"); - MQLONG queueTypeValue = dictionary()->getDisplayId(MQIA_Q_TYPE, queueType); - poco_assert_dbg(queueTypeValue != -1); - if ( queueTypeValue == - 1 ) - { - return jsonQueues; - } - inquireQ->addParameter(MQIA_Q_TYPE, queueTypeValue); - - handleAttrs(inquireQ, filter, "QAttrs", MQIACF_Q_ATTRS); - PCF::Vector commandResponse; - _commandServer.sendCommand(inquireQ, commandResponse); + command.execute(commandResponse); bool excludeSystem = filter->optValue("ExcludeSystem", false); bool excludeTemp = filter->optValue("ExcludeTemp", false); + Poco::JSON::Array::Ptr jsonQueues = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->isExtendedResponse() ) // Skip extended response diff --git a/MQWeb/src/QueueStatusMapper.cpp b/MQWeb/src/QueueStatusMapper.cpp index e0a39f2..19274d4 100644 --- a/MQWeb/src/QueueStatusMapper.cpp +++ b/MQWeb/src/QueueStatusMapper.cpp @@ -58,33 +58,26 @@ Poco::JSON::Array::Ptr QueueStatusMapper::inquire(const Poco::JSON::Object::Ptr& Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); - PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_Q_STATUS); - command->addParameter(MQCA_Q_NAME, filter->optValue("queueName", "*")); + Command command(this, MQCMD_INQUIRE_Q_STATUS, filter); - if ( filter->has("openType") ) - { - std::string type = filter->optValue("openType", "All"); - MQLONG typeValue = dictionary()->getDisplayId(MQIACF_OPEN_TYPE, type); - poco_assert_dbg(typeValue != -1); - if ( typeValue != MQQSOT_ALL ) - { - command->addParameter(MQIACF_OPEN_TYPE, typeValue); - } - } + // Required parameters + command.addParameter(MQCA_Q_NAME, "QName"); - if ( filter->has("statusType") ) - { - std::string type = filter->optValue("statusType", "Queue Status"); - MQLONG typeValue = dictionary()->getDisplayId(MQIACF_STATUS_TYPE, type); - poco_assert_dbg(typeValue != -1); - command->addParameter(MQIACF_STATUS_TYPE, typeValue); - } + // Optional parameters + //TODO: ByteStringFilter + command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + command.addIntegerFilter(); + command.addParameterNumFromString(MQIACF_OPEN_TYPE, "OpenType"); + command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + command.addAttributeList(MQIACF_Q_STATUS_ATTRS, "QStatusAttrs"); + command.addParameterNumFromString(MQIACF_STATUS_TYPE, "StatusType"); + command.addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(command, commandResponse); + command.execute(commandResponse); - bool excludeSystem = filter->optValue("excludeSystem", false); - bool excludeTemp = filter->optValue("excludeTemp", false); + bool excludeSystem = filter->optValue("ExcludeSystem", false); + bool excludeTemp = filter->optValue("ExcludeTemp", false); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { diff --git a/MQWeb/src/ServiceMapper.cpp b/MQWeb/src/ServiceMapper.cpp index a820b55..0eb4c14 100644 --- a/MQWeb/src/ServiceMapper.cpp +++ b/MQWeb/src/ServiceMapper.cpp @@ -58,17 +58,22 @@ Poco::JSON::Array::Ptr ServiceMapper::inquire(const Poco::JSON::Object::Ptr& fil { poco_assert_dbg(!filter.isNull()); - Poco::JSON::Array::Ptr services = new Poco::JSON::Array(); + Command command(this, MQCMD_INQUIRE_SERVICE, filter); - PCF::Ptr inquireService = _commandServer.createCommand(MQCMD_INQUIRE_SERVICE); + // Required parameters + command.addParameter(MQCA_SERVICE_NAME, "ServiceName"); - inquireService->addParameter(MQCA_SERVICE_NAME, filter->optValue("name", "*")); + // Optional parameters + command.addIntegerFilter(); + command.addAttributeList(MQIACF_SERVICE_ATTRS, "ServiceAttrs"); + command.addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireService, commandResponse); + command.execute(commandResponse); - bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeSystem = filter->optValue("ExcludeSystem", false); + Poco::JSON::Array::Ptr services = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) From 7f2aecf6c48db0b3cb23cc4c7c16ff8413ca1518 Mon Sep 17 00:00:00 2001 From: fbraem Date: Sat, 30 Aug 2014 21:27:37 +0200 Subject: [PATCH 038/143] Add argument for queuemanagername --- samples/queue.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/queue.pl b/samples/queue.pl index cc931e3..ff78098 100644 --- a/samples/queue.pl +++ b/samples/queue.pl @@ -4,14 +4,16 @@ use LWP::UserAgent; use HTTP::Request::Common; +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); my $json = '{ "QName" : "T*" }'; my $ua = LWP::UserAgent->new; -my $req = POST 'http://localhost:8081/api/queue/inquire/EAGLE'; +my $req = POST 'http://localhost:8081/api/queue/inquire/' . $qmgr; $req->header( 'Content-Type' => 'application/json' ); $req->content($json); my $res = $ua->request($req); -print $res->content(); \ No newline at end of file +print $res->content(); From 1a9ac0c4358fa01cf69823b4bf459ae684b2d3b3 Mon Sep 17 00:00:00 2001 From: fbraem Date: Sat, 30 Aug 2014 21:27:54 +0200 Subject: [PATCH 039/143] Correct URL and inquire for SYSTEM queues --- samples/queue.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/samples/queue.php b/samples/queue.php index d9fa73d..fe5bca1 100644 --- a/samples/queue.php +++ b/samples/queue.php @@ -1,10 +1,10 @@ Date: Sun, 31 Aug 2014 19:57:50 +0200 Subject: [PATCH 040/143] Add more query parameters --- MQWeb/src/QueueController.cpp | 57 +++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index fe0766d..04bdbdb 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -62,20 +62,51 @@ void QueueController::inquire() else { // Handle query parameters - std::string queueNameField; + std::string queueName; if ( form().has("QName") ) { - queueNameField = form().get("QName"); + queueName = form().get("QName"); } else { - queueNameField = form().get("queueName", "*"); + queueName = form().get("QueueName", "*"); } - if ( queueNameField.empty() ) + if ( queueName.empty() ) { - queueNameField = "*"; + queueName = "*"; } - pcfParameters->set("QName", queueNameField); + pcfParameters->set("QName", queueName); + } + + if ( form().has("ClusterInfo") ) + { + std::string clusterInfo = form().get("ClusterInfo"); + pcfParameters->set("ClusterInfo", Poco::icompare(clusterInfo, "true") == 0 ? "true" : "false"); + } + + if ( form().has("ClusterName") ) + { + pcfParameters->set("ClusterName", form().get("ClusterName")); + } + + if ( form().has("ClusterNameList") ) + { + pcfParameters->set("ClusterNamelist", form().get("ClusterNamelist")); + } + + if ( form().has("CommandScope") ) + { + pcfParameters->set("CommandScope", form().get("CommandScope")); + } + + if ( form().has("PageSetId") ) + { + pcfParameters->set("PageSetId", form().get("PageSetId")); + } + + if ( form().has("QSGDisposition") ) + { + pcfParameters->set("QSGDisposition", form().get("QSGDisposition")); } std::string queueDepthField; @@ -83,9 +114,9 @@ void QueueController::inquire() { queueDepthField = form().get("CurrentQDepth", ""); } - else if ( form().has("queueDepth")) + else if ( form().has("QueueDepth")) { - queueDepthField = form().get("queueDepth", ""); + queueDepthField = form().get("QueueDepth", ""); } if ( !queueDepthField.empty() ) { @@ -102,9 +133,9 @@ void QueueController::inquire() handleFilterForm(pcfParameters); - if ( form().has("queueUsage") ) + if ( form().has("QueueUsage") ) { - pcfParameters->set("Usage", form().get("queueUsage")); + pcfParameters->set("Usage", form().get("QueueUsage")); } else if ( form().has("Usage") ) { @@ -112,9 +143,9 @@ void QueueController::inquire() } std::string queueType; - if ( form().has("queueType") ) + if ( form().has("QueueType") ) { - queueType = form().get("queueType"); + queueType = form().get("QueueType"); } else { @@ -122,7 +153,7 @@ void QueueController::inquire() } if ( !queueType.empty() ) { - pcfParameters->set("QType", form().get("queueType", "All")); + pcfParameters->set("QType", queueType); } pcfParameters->set("ExcludeSystem", form().get("excludeSystem", "false").compare("true") == 0); From cb6bb5eb219142d5e3dd9f3d41c8ef3807bfa3a6 Mon Sep 17 00:00:00 2001 From: fbraem Date: Sun, 31 Aug 2014 19:58:31 +0200 Subject: [PATCH 041/143] ClusterInfo is boolean / Add QSGDisposition --- MQWeb/src/QueueMapper.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MQWeb/src/QueueMapper.cpp b/MQWeb/src/QueueMapper.cpp index 7a02f11..2ba9f1c 100644 --- a/MQWeb/src/QueueMapper.cpp +++ b/MQWeb/src/QueueMapper.cpp @@ -63,7 +63,19 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte // Optional Parameters command.addParameter(MQCA_CF_STRUC_NAME, "CFStructure"); - command.addParameter(MQIACF_CLUSTER_INFO, "ClusterInfo"); + + Poco::Dynamic::Var clusterInfo = filter->get("ClusterInfo"); + if (! clusterInfo.isEmpty() ) + { + try + { + command.pcf()->addParameter(MQIACF_CLUSTER_INFO, clusterInfo.convert() == true); + } + catch(...) + { + poco_assert_dbg(false); + } + } command.addParameter(MQCA_CLUSTER_NAME, "ClusterName"); command.addParameter(MQCA_CLUSTER_NAMELIST, "ClusterNamelist"); command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); @@ -72,6 +84,7 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte command.addStringFilter(); command.addParameterNumFromString(MQIA_Q_TYPE, "QType"); command.addAttributeList(MQIACF_Q_ATTRS, "QAttrs"); + command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); MQLONG usage = -1; if ( filter->has("Usage") ) From 40ede4e8bf4cbca81fbd23b68155873203f47ee0 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Mon, 1 Sep 2014 13:25:47 +0200 Subject: [PATCH 042/143] Numeric PageSetId --- MQWeb/src/QueueController.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index 04bdbdb..8535f55 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -101,7 +101,11 @@ void QueueController::inquire() if ( form().has("PageSetId") ) { - pcfParameters->set("PageSetId", form().get("PageSetId")); + int pageSetId = 0; + if ( Poco::NumberParser::tryParse(form().get("PageSetId"), pageSetId) ) + { + pcfParameters->set("PageSetId", pageSetId); + } } if ( form().has("QSGDisposition") ) @@ -156,8 +160,8 @@ void QueueController::inquire() pcfParameters->set("QType", queueType); } - pcfParameters->set("ExcludeSystem", form().get("excludeSystem", "false").compare("true") == 0); - pcfParameters->set("ExcludeTemp", form().get("excludeTemp", "false").compare("true") == 0); + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + pcfParameters->set("ExcludeTemp", form().get("ExcludeTemp", "false").compare("true") == 0); Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); pcfParameters->set("QAttrs", attrs); From a2036bf199a9526459159c6e9a528c39668fad6f Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 1 Sep 2014 20:44:57 +0200 Subject: [PATCH 043/143] Add name as synonym for QName --- MQWeb/src/QueueController.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index 8535f55..7e9fa7b 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -67,10 +67,15 @@ void QueueController::inquire() { queueName = form().get("QName"); } - else + else if ( form().has("QueueName") ) { - queueName = form().get("QueueName", "*"); + queueName = form().get("QueueName"); } + else if ( form().has("name") ) + { + queueName = form().get("name"); + } + if ( queueName.empty() ) { queueName = "*"; From 29d090a6442370964a3a8430b50fff4967db0635 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 5 Sep 2014 19:10:32 +0200 Subject: [PATCH 044/143] throw exception when the first PCF answer contains a PCF reason code --- MQWeb/include/MQ/Web/MQMapper.h | 6 ------ MQWeb/src/MQMapper.cpp | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/MQWeb/include/MQ/Web/MQMapper.h b/MQWeb/include/MQ/Web/MQMapper.h index 97f403b..e050194 100644 --- a/MQWeb/include/MQ/Web/MQMapper.h +++ b/MQWeb/include/MQ/Web/MQMapper.h @@ -141,12 +141,6 @@ inline const Poco::SharedPtr MQMapper::dictionary(const std::string& return _dictionaryCache.getDictionary(objectType); } -inline void MQMapper::Command::execute(PCF::Vector& response) -{ - poco_check_ptr(_pcf); - _mapper->_commandServer.sendCommand(_pcf, response); -} - inline PCF::Ptr MQMapper::Command::pcf() { return _pcf; diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index 24e86e0..2f71ce9 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -20,6 +20,8 @@ */ #include "MQ/Web/MQMapper.h" +#include "MQ/MQException.h" + #include "Poco/JSON/Object.h" #include "Poco/Logger.h" @@ -187,4 +189,21 @@ void MQMapper::Command::addParameterNumFromString(MQLONG parameter, const std::s } } +void MQMapper::Command::execute(PCF::Vector& response) +{ + poco_check_ptr(_pcf); + _mapper->_commandServer.sendCommand(_pcf, response); + + if ( response.size() > 0 ) + { + PCF::Vector::const_iterator it = response.begin(); + if ( (*it)->getCompletionCode() == MQCC_FAILED && (*it)->getReasonCode() > 3000 && (*it)->getReasonCode() < 4000 ) + { + static Poco::SharedPtr dict = _dictionaryCache.getDictionary("Event"); + std::string command = dict->getDisplayValue(MQIACF_COMMAND, (*it)->getCommand()); + throw MQException("PCF", command, (*it)->getCompletionCode(), (*it)->getReasonCode()); + } + } +} + }} // Namespace MQ::Web From 73271f1dd724707cd5b45970f52f7466eafe8d4d Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 5 Sep 2014 19:11:19 +0200 Subject: [PATCH 045/143] Add PCF reason codes and more Command constants --- MQDictionary/src/Application.cpp | 558 ++++++++++++++++++++++++------- 1 file changed, 442 insertions(+), 116 deletions(-) diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 5f1db21..f00163f 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -1356,122 +1356,195 @@ Dictionary eventDictionary = Dictionary() (MQIACH_CHANNEL_TYPE) (MQCACH_CLIENT_USER_ID, "ClientUserIdentifier") (MQIACF_COMMAND, "Command", DisplayMapInitializer - MQCONST2STR(MQCMD_ARCHIVE_LOG) - MQCONST2STR(MQCMD_BACKUP_CF_STRUC) - MQCONST2STR(MQCMD_CHANGE_AUTH_INFO) - MQCONST2STR(MQCMD_CHANGE_BUFFER_POOL) - MQCONST2STR(MQCMD_CHANGE_CF_STRUC) - MQCONST2STR(MQCMD_CHANGE_CHANNEL) - MQCONST2STR(MQCMD_CHANGE_COMM_INFO) - MQCONST2STR(MQCMD_CHANGE_LISTENER) - MQCONST2STR(MQCMD_CHANGE_NAMELIST) - MQCONST2STR(MQCMD_CHANGE_PAGE_SET) - MQCONST2STR(MQCMD_CHANGE_PROCESS) - MQCONST2STR(MQCMD_CHANGE_Q) - MQCONST2STR(MQCMD_CHANGE_Q_MGR) - MQCONST2STR(MQCMD_CHANGE_SECURITY) - MQCONST2STR(MQCMD_CHANGE_SERVICE) - MQCONST2STR(MQCMD_CHANGE_STG_CLASS) - MQCONST2STR(MQCMD_CHANGE_SUBSCRIPTION) - MQCONST2STR(MQCMD_CHANGE_TOPIC) - MQCONST2STR(MQCMD_CHANGE_TRACE) - MQCONST2STR(MQCMD_CLEAR_Q) - MQCONST2STR(MQCMD_CLEAR_TOPIC_STRING) - MQCONST2STR(MQCMD_CREATE_AUTH_INFO) - MQCONST2STR(MQCMD_CREATE_BUFFER_POOL) - MQCONST2STR(MQCMD_CREATE_CF_STRUC) - MQCONST2STR(MQCMD_CREATE_CHANNEL) - MQCONST2STR(MQCMD_CREATE_COMM_INFO) - MQCONST2STR(MQCMD_CREATE_LISTENER) - MQCONST2STR(MQCMD_CREATE_NAMELIST) - MQCONST2STR(MQCMD_CREATE_PAGE_SET) - MQCONST2STR(MQCMD_CREATE_PROCESS) - MQCONST2STR(MQCMD_CREATE_Q) - MQCONST2STR(MQCMD_CREATE_SERVICE) - MQCONST2STR(MQCMD_CREATE_STG_CLASS) - MQCONST2STR(MQCMD_CREATE_SUBSCRIPTION) - MQCONST2STR(MQCMD_CREATE_TOPIC) - MQCONST2STR(MQCMD_DELETE_AUTH_INFO) - MQCONST2STR(MQCMD_DELETE_CF_STRUC) - MQCONST2STR(MQCMD_DELETE_CHANNEL) - MQCONST2STR(MQCMD_DELETE_COMM_INFO) - MQCONST2STR(MQCMD_DELETE_LISTENER) - MQCONST2STR(MQCMD_DELETE_NAMELIST) - MQCONST2STR(MQCMD_DELETE_PAGE_SET) - MQCONST2STR(MQCMD_DELETE_PROCESS) - MQCONST2STR(MQCMD_DELETE_Q) - MQCONST2STR(MQCMD_DELETE_SERVICE) - MQCONST2STR(MQCMD_DELETE_STG_CLASS) - MQCONST2STR(MQCMD_DELETE_SUBSCRIPTION) - MQCONST2STR(MQCMD_DELETE_TOPIC) - MQCONST2STR(MQCMD_INQUIRE_ARCHIVE) - MQCONST2STR(MQCMD_INQUIRE_AUTH_INFO) - MQCONST2STR(MQCMD_INQUIRE_CF_STRUC) - MQCONST2STR(MQCMD_INQUIRE_CF_STRUC_STATUS) - MQCONST2STR(MQCMD_INQUIRE_CHANNEL) - MQCONST2STR(MQCMD_INQUIRE_CHANNEL_INIT) - MQCONST2STR(MQCMD_INQUIRE_CHANNEL_STATUS) - MQCONST2STR(MQCMD_INQUIRE_CHLAUTH_RECS) - MQCONST2STR(MQCMD_INQUIRE_CLUSTER_Q_MGR) - MQCONST2STR(MQCMD_INQUIRE_CMD_SERVER) - MQCONST2STR(MQCMD_INQUIRE_COMM_INFO) - MQCONST2STR(MQCMD_INQUIRE_CONNECTION) - MQCONST2STR(MQCMD_INQUIRE_LISTENER) - MQCONST2STR(MQCMD_INQUIRE_LOG) - MQCONST2STR(MQCMD_INQUIRE_NAMELIST) - MQCONST2STR(MQCMD_INQUIRE_PROCESS) - MQCONST2STR(MQCMD_INQUIRE_PUBSUB_STATUS) - MQCONST2STR(MQCMD_INQUIRE_Q) - MQCONST2STR(MQCMD_INQUIRE_Q_MGR) - MQCONST2STR(MQCMD_INQUIRE_QSG) - MQCONST2STR(MQCMD_INQUIRE_Q_STATUS) - MQCONST2STR(MQCMD_INQUIRE_SECURITY) - MQCONST2STR(MQCMD_INQUIRE_SERVICE) - MQCONST2STR(MQCMD_INQUIRE_STG_CLASS) - MQCONST2STR(MQCMD_INQUIRE_SUBSCRIPTION) - MQCONST2STR(MQCMD_INQUIRE_SUB_STATUS) - MQCONST2STR(MQCMD_INQUIRE_SYSTEM) - MQCONST2STR(MQCMD_INQUIRE_THREAD) - MQCONST2STR(MQCMD_INQUIRE_TOPIC) - MQCONST2STR(MQCMD_INQUIRE_TOPIC_STATUS) - MQCONST2STR(MQCMD_INQUIRE_TRACE) - MQCONST2STR(MQCMD_INQUIRE_USAGE) - MQCONST2STR(MQCMD_MOVE_Q) - MQCONST2STR(MQCMD_PING_CHANNEL) - MQCONST2STR(MQCMD_RECOVER_BSDS) - MQCONST2STR(MQCMD_RECOVER_CF_STRUC) - MQCONST2STR(MQCMD_REFRESH_CLUSTER) - MQCONST2STR(MQCMD_REFRESH_Q_MGR) - MQCONST2STR(MQCMD_REFRESH_SECURITY) - MQCONST2STR(MQCMD_RESET_CHANNEL) - MQCONST2STR(MQCMD_RESET_CLUSTER) - MQCONST2STR(MQCMD_RESET_Q_MGR) - MQCONST2STR(MQCMD_RESET_Q_STATS) - MQCONST2STR(MQCMD_RESET_TPIPE) - MQCONST2STR(MQCMD_RESOLVE_CHANNEL) - MQCONST2STR(MQCMD_RESOLVE_INDOUBT) - MQCONST2STR(MQCMD_RESUME_Q_MGR) - MQCONST2STR(MQCMD_RESUME_Q_MGR_CLUSTER) - MQCONST2STR(MQCMD_REVERIFY_SECURITY) - MQCONST2STR(MQCMD_SET_ARCHIVE) - MQCONST2STR(MQCMD_SET_CHLAUTH_REC) - MQCONST2STR(MQCMD_SET_LOG) - MQCONST2STR(MQCMD_SET_SYSTEM) - MQCONST2STR(MQCMD_START_CHANNEL) - MQCONST2STR(MQCMD_START_CHANNEL_INIT) - MQCONST2STR(MQCMD_START_CHANNEL_LISTENER) - MQCONST2STR(MQCMD_START_CMD_SERVER) - MQCONST2STR(MQCMD_START_SERVICE) - MQCONST2STR(MQCMD_START_TRACE) - MQCONST2STR(MQCMD_STOP_CHANNEL) - MQCONST2STR(MQCMD_STOP_CHANNEL_INIT) - MQCONST2STR(MQCMD_STOP_CHANNEL_LISTENER) - MQCONST2STR(MQCMD_STOP_CMD_SERVER) - MQCONST2STR(MQCMD_STOP_CONNECTION) - MQCONST2STR(MQCMD_STOP_SERVICE) - MQCONST2STR(MQCMD_STOP_TRACE) - MQCONST2STR(MQCMD_SUSPEND_Q_MGR) - MQCONST2STR(MQCMD_SUSPEND_Q_MGR_CLUSTER) + MQCONST2STR(MQCMD_CHANGE_Q_MGR ) + MQCONST2STR(MQCMD_INQUIRE_Q_MGR ) + MQCONST2STR(MQCMD_CHANGE_PROCESS ) + MQCONST2STR(MQCMD_COPY_PROCESS ) + MQCONST2STR(MQCMD_CREATE_PROCESS ) + MQCONST2STR(MQCMD_DELETE_PROCESS ) + MQCONST2STR(MQCMD_INQUIRE_PROCESS ) + MQCONST2STR(MQCMD_CHANGE_Q ) + MQCONST2STR(MQCMD_CLEAR_Q ) + MQCONST2STR(MQCMD_COPY_Q ) + MQCONST2STR(MQCMD_CREATE_Q ) + MQCONST2STR(MQCMD_DELETE_Q ) + MQCONST2STR(MQCMD_INQUIRE_Q ) + MQCONST2STR(MQCMD_REFRESH_Q_MGR ) + MQCONST2STR(MQCMD_RESET_Q_STATS ) + MQCONST2STR(MQCMD_INQUIRE_Q_NAMES ) + MQCONST2STR(MQCMD_INQUIRE_PROCESS_NAMES ) + MQCONST2STR(MQCMD_INQUIRE_CHANNEL_NAMES ) + MQCONST2STR(MQCMD_CHANGE_CHANNEL ) + MQCONST2STR(MQCMD_COPY_CHANNEL ) + MQCONST2STR(MQCMD_CREATE_CHANNEL ) + MQCONST2STR(MQCMD_DELETE_CHANNEL ) + MQCONST2STR(MQCMD_INQUIRE_CHANNEL ) + MQCONST2STR(MQCMD_PING_CHANNEL ) + MQCONST2STR(MQCMD_RESET_CHANNEL ) + MQCONST2STR(MQCMD_START_CHANNEL ) + MQCONST2STR(MQCMD_STOP_CHANNEL ) + MQCONST2STR(MQCMD_START_CHANNEL_INIT ) + MQCONST2STR(MQCMD_START_CHANNEL_LISTENER ) + MQCONST2STR(MQCMD_CHANGE_NAMELIST ) + MQCONST2STR(MQCMD_COPY_NAMELIST ) + MQCONST2STR(MQCMD_CREATE_NAMELIST ) + MQCONST2STR(MQCMD_DELETE_NAMELIST ) + MQCONST2STR(MQCMD_INQUIRE_NAMELIST ) + MQCONST2STR(MQCMD_INQUIRE_NAMELIST_NAMES ) + MQCONST2STR(MQCMD_ESCAPE ) + MQCONST2STR(MQCMD_RESOLVE_CHANNEL ) + MQCONST2STR(MQCMD_PING_Q_MGR ) + MQCONST2STR(MQCMD_INQUIRE_Q_STATUS ) + MQCONST2STR(MQCMD_INQUIRE_CHANNEL_STATUS ) + MQCONST2STR(MQCMD_CONFIG_EVENT ) + MQCONST2STR(MQCMD_Q_MGR_EVENT ) + MQCONST2STR(MQCMD_PERFM_EVENT ) + MQCONST2STR(MQCMD_CHANNEL_EVENT ) + MQCONST2STR(MQCMD_DELETE_PUBLICATION ) + MQCONST2STR(MQCMD_DEREGISTER_PUBLISHER ) + MQCONST2STR(MQCMD_DEREGISTER_SUBSCRIBER ) + MQCONST2STR(MQCMD_PUBLISH ) + MQCONST2STR(MQCMD_REGISTER_PUBLISHER ) + MQCONST2STR(MQCMD_REGISTER_SUBSCRIBER ) + MQCONST2STR(MQCMD_REQUEST_UPDATE ) + MQCONST2STR(MQCMD_BROKER_INTERNAL ) + MQCONST2STR(MQCMD_ACTIVITY_MSG ) + MQCONST2STR(MQCMD_INQUIRE_CLUSTER_Q_MGR ) + MQCONST2STR(MQCMD_RESUME_Q_MGR_CLUSTER ) + MQCONST2STR(MQCMD_SUSPEND_Q_MGR_CLUSTER ) + MQCONST2STR(MQCMD_REFRESH_CLUSTER ) + MQCONST2STR(MQCMD_RESET_CLUSTER ) + MQCONST2STR(MQCMD_TRACE_ROUTE ) + MQCONST2STR(MQCMD_REFRESH_SECURITY ) + MQCONST2STR(MQCMD_CHANGE_AUTH_INFO ) + MQCONST2STR(MQCMD_COPY_AUTH_INFO ) + MQCONST2STR(MQCMD_CREATE_AUTH_INFO ) + MQCONST2STR(MQCMD_DELETE_AUTH_INFO ) + MQCONST2STR(MQCMD_INQUIRE_AUTH_INFO ) + MQCONST2STR(MQCMD_INQUIRE_AUTH_INFO_NAMES ) + MQCONST2STR(MQCMD_INQUIRE_CONNECTION ) + MQCONST2STR(MQCMD_STOP_CONNECTION ) + MQCONST2STR(MQCMD_INQUIRE_AUTH_RECS ) + MQCONST2STR(MQCMD_INQUIRE_ENTITY_AUTH ) + MQCONST2STR(MQCMD_DELETE_AUTH_REC ) + MQCONST2STR(MQCMD_SET_AUTH_REC ) + MQCONST2STR(MQCMD_LOGGER_EVENT ) + MQCONST2STR(MQCMD_RESET_Q_MGR ) + MQCONST2STR(MQCMD_CHANGE_LISTENER ) + MQCONST2STR(MQCMD_COPY_LISTENER ) + MQCONST2STR(MQCMD_CREATE_LISTENER ) + MQCONST2STR(MQCMD_DELETE_LISTENER ) + MQCONST2STR(MQCMD_INQUIRE_LISTENER ) + MQCONST2STR(MQCMD_INQUIRE_LISTENER_STATUS ) + MQCONST2STR(MQCMD_COMMAND_EVENT ) + MQCONST2STR(MQCMD_CHANGE_SECURITY ) + MQCONST2STR(MQCMD_CHANGE_CF_STRUC ) + MQCONST2STR(MQCMD_CHANGE_STG_CLASS ) + MQCONST2STR(MQCMD_CHANGE_TRACE ) + MQCONST2STR(MQCMD_ARCHIVE_LOG ) + MQCONST2STR(MQCMD_BACKUP_CF_STRUC ) + MQCONST2STR(MQCMD_CREATE_BUFFER_POOL ) + MQCONST2STR(MQCMD_CREATE_PAGE_SET ) + MQCONST2STR(MQCMD_CREATE_CF_STRUC ) + MQCONST2STR(MQCMD_CREATE_STG_CLASS ) + MQCONST2STR(MQCMD_COPY_CF_STRUC ) + MQCONST2STR(MQCMD_COPY_STG_CLASS ) + MQCONST2STR(MQCMD_DELETE_CF_STRUC ) + MQCONST2STR(MQCMD_DELETE_STG_CLASS ) + MQCONST2STR(MQCMD_INQUIRE_ARCHIVE ) + MQCONST2STR(MQCMD_INQUIRE_CF_STRUC ) + MQCONST2STR(MQCMD_INQUIRE_CF_STRUC_STATUS ) + MQCONST2STR(MQCMD_INQUIRE_CMD_SERVER ) + MQCONST2STR(MQCMD_INQUIRE_CHANNEL_INIT ) + MQCONST2STR(MQCMD_INQUIRE_QSG ) + MQCONST2STR(MQCMD_INQUIRE_LOG ) + MQCONST2STR(MQCMD_INQUIRE_SECURITY ) + MQCONST2STR(MQCMD_INQUIRE_STG_CLASS ) + MQCONST2STR(MQCMD_INQUIRE_SYSTEM ) + MQCONST2STR(MQCMD_INQUIRE_THREAD ) + MQCONST2STR(MQCMD_INQUIRE_TRACE ) + MQCONST2STR(MQCMD_INQUIRE_USAGE ) + MQCONST2STR(MQCMD_MOVE_Q ) + MQCONST2STR(MQCMD_RECOVER_BSDS ) + MQCONST2STR(MQCMD_RECOVER_CF_STRUC ) + MQCONST2STR(MQCMD_RESET_TPIPE ) + MQCONST2STR(MQCMD_RESOLVE_INDOUBT ) + MQCONST2STR(MQCMD_RESUME_Q_MGR ) + MQCONST2STR(MQCMD_REVERIFY_SECURITY ) + MQCONST2STR(MQCMD_SET_ARCHIVE ) + MQCONST2STR(MQCMD_SET_LOG ) + MQCONST2STR(MQCMD_SET_SYSTEM ) + MQCONST2STR(MQCMD_START_CMD_SERVER ) + MQCONST2STR(MQCMD_START_Q_MGR ) + MQCONST2STR(MQCMD_START_TRACE ) + MQCONST2STR(MQCMD_STOP_CHANNEL_INIT ) + MQCONST2STR(MQCMD_STOP_CHANNEL_LISTENER ) + MQCONST2STR(MQCMD_STOP_CMD_SERVER ) + MQCONST2STR(MQCMD_STOP_Q_MGR ) + MQCONST2STR(MQCMD_STOP_TRACE ) + MQCONST2STR(MQCMD_SUSPEND_Q_MGR ) + MQCONST2STR(MQCMD_INQUIRE_CF_STRUC_NAMES ) + MQCONST2STR(MQCMD_INQUIRE_STG_CLASS_NAMES ) + MQCONST2STR(MQCMD_CHANGE_SERVICE ) + MQCONST2STR(MQCMD_COPY_SERVICE ) + MQCONST2STR(MQCMD_CREATE_SERVICE ) + MQCONST2STR(MQCMD_DELETE_SERVICE ) + MQCONST2STR(MQCMD_INQUIRE_SERVICE ) + MQCONST2STR(MQCMD_INQUIRE_SERVICE_STATUS ) + MQCONST2STR(MQCMD_START_SERVICE ) + MQCONST2STR(MQCMD_STOP_SERVICE ) + MQCONST2STR(MQCMD_DELETE_BUFFER_POOL ) + MQCONST2STR(MQCMD_DELETE_PAGE_SET ) + MQCONST2STR(MQCMD_CHANGE_BUFFER_POOL ) + MQCONST2STR(MQCMD_CHANGE_PAGE_SET ) + MQCONST2STR(MQCMD_INQUIRE_Q_MGR_STATUS ) + MQCONST2STR(MQCMD_CREATE_LOG ) + MQCONST2STR(MQCMD_STATISTICS_MQI ) + MQCONST2STR(MQCMD_STATISTICS_Q ) + MQCONST2STR(MQCMD_STATISTICS_CHANNEL ) + MQCONST2STR(MQCMD_ACCOUNTING_MQI ) + MQCONST2STR(MQCMD_ACCOUNTING_Q ) + MQCONST2STR(MQCMD_INQUIRE_AUTH_SERVICE ) + MQCONST2STR(MQCMD_CHANGE_TOPIC ) + MQCONST2STR(MQCMD_COPY_TOPIC ) + MQCONST2STR(MQCMD_CREATE_TOPIC ) + MQCONST2STR(MQCMD_DELETE_TOPIC ) + MQCONST2STR(MQCMD_INQUIRE_TOPIC ) + MQCONST2STR(MQCMD_INQUIRE_TOPIC_NAMES ) + MQCONST2STR(MQCMD_INQUIRE_SUBSCRIPTION ) + MQCONST2STR(MQCMD_CREATE_SUBSCRIPTION ) + MQCONST2STR(MQCMD_CHANGE_SUBSCRIPTION ) + MQCONST2STR(MQCMD_DELETE_SUBSCRIPTION ) + MQCONST2STR(MQCMD_COPY_SUBSCRIPTION ) + MQCONST2STR(MQCMD_INQUIRE_SUB_STATUS ) + MQCONST2STR(MQCMD_INQUIRE_TOPIC_STATUS ) + MQCONST2STR(MQCMD_CLEAR_TOPIC_STRING ) + MQCONST2STR(MQCMD_INQUIRE_PUBSUB_STATUS ) + MQCONST2STR(MQCMD_INQUIRE_SMDS ) + MQCONST2STR(MQCMD_CHANGE_SMDS ) + MQCONST2STR(MQCMD_RESET_SMDS ) + MQCONST2STR(MQCMD_CREATE_COMM_INFO ) + MQCONST2STR(MQCMD_INQUIRE_COMM_INFO ) + MQCONST2STR(MQCMD_CHANGE_COMM_INFO ) + MQCONST2STR(MQCMD_COPY_COMM_INFO ) + MQCONST2STR(MQCMD_DELETE_COMM_INFO ) + MQCONST2STR(MQCMD_PURGE_CHANNEL ) + MQCONST2STR(MQCMD_MQXR_DIAGNOSTICS ) + MQCONST2STR(MQCMD_START_SMDSCONN ) + MQCONST2STR(MQCMD_STOP_SMDSCONN ) + MQCONST2STR(MQCMD_INQUIRE_SMDSCONN ) + MQCONST2STR(MQCMD_INQUIRE_MQXR_STATUS ) + MQCONST2STR(MQCMD_START_CLIENT_TRACE ) + MQCONST2STR(MQCMD_STOP_CLIENT_TRACE ) + MQCONST2STR(MQCMD_SET_CHLAUTH_REC ) + MQCONST2STR(MQCMD_INQUIRE_CHLAUTH_RECS ) + MQCONST2STR(MQCMD_INQUIRE_PROT_POLICY ) + MQCONST2STR(MQCMD_CREATE_PROT_POLICY ) + MQCONST2STR(MQCMD_DELETE_PROT_POLICY ) + MQCONST2STR(MQCMD_CHANGE_PROT_POLICY ) + MQCONST2STR(MQCMD_ACTIVITY_TRACE ) + MQCONST2STR(MQCMD_RESET_CF_STRUC ) + MQCONST2STR(MQCMD_INQUIRE_XR_CAPABILITY ) ) (MQGACF_COMMAND_CONTEXT, "CommandContext") (MQGACF_COMMAND_DATA, "CommandData") @@ -2141,6 +2214,259 @@ Dictionary reasonDictionary = Dictionary() MQCONST2STR(MQRC_PRECONN_EXIT_ERROR ) MQCONST2STR(MQRC_CD_ARRAY_ERROR ) + // PCF Reason Codes + MQCONST2STR(MQRCCF_CFH_TYPE_ERROR ) + MQCONST2STR(MQRCCF_CFH_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFH_VERSION_ERROR ) + MQCONST2STR(MQRCCF_CFH_MSG_SEQ_NUMBER_ERR ) + MQCONST2STR(MQRCCF_CFH_CONTROL_ERROR ) + MQCONST2STR(MQRCCF_CFH_PARM_COUNT_ERROR ) + MQCONST2STR(MQRCCF_CFH_COMMAND_ERROR ) + MQCONST2STR(MQRCCF_COMMAND_FAILED ) + MQCONST2STR(MQRCCF_CFIN_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFST_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFST_STRING_LENGTH_ERR ) + MQCONST2STR(MQRCCF_FORCE_VALUE_ERROR ) + MQCONST2STR(MQRCCF_STRUCTURE_TYPE_ERROR ) + MQCONST2STR(MQRCCF_CFIN_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_CFST_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_MSG_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFIN_DUPLICATE_PARM ) + MQCONST2STR(MQRCCF_CFST_DUPLICATE_PARM ) + MQCONST2STR(MQRCCF_PARM_COUNT_TOO_SMALL ) + MQCONST2STR(MQRCCF_PARM_COUNT_TOO_BIG ) + MQCONST2STR(MQRCCF_Q_ALREADY_IN_CELL ) + MQCONST2STR(MQRCCF_Q_TYPE_ERROR ) + MQCONST2STR(MQRCCF_MD_FORMAT_ERROR ) + MQCONST2STR(MQRCCF_CFSL_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_REPLACE_VALUE_ERROR ) + MQCONST2STR(MQRCCF_CFIL_DUPLICATE_VALUE ) + MQCONST2STR(MQRCCF_CFIL_COUNT_ERROR ) + MQCONST2STR(MQRCCF_CFIL_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_QUIESCE_VALUE_ERROR ) + MQCONST2STR(MQRCCF_MODE_VALUE_ERROR ) + MQCONST2STR(MQRCCF_MSG_SEQ_NUMBER_ERROR ) + MQCONST2STR(MQRCCF_PING_DATA_COUNT_ERROR ) + MQCONST2STR(MQRCCF_PING_DATA_COMPARE_ERROR ) + MQCONST2STR(MQRCCF_CFSL_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_CHANNEL_TYPE_ERROR ) + MQCONST2STR(MQRCCF_PARM_SEQUENCE_ERROR ) + MQCONST2STR(MQRCCF_XMIT_PROTOCOL_TYPE_ERR ) + MQCONST2STR(MQRCCF_BATCH_SIZE_ERROR ) + MQCONST2STR(MQRCCF_DISC_INT_ERROR ) + MQCONST2STR(MQRCCF_SHORT_RETRY_ERROR ) + MQCONST2STR(MQRCCF_SHORT_TIMER_ERROR ) + MQCONST2STR(MQRCCF_LONG_RETRY_ERROR ) + MQCONST2STR(MQRCCF_LONG_TIMER_ERROR ) + MQCONST2STR(MQRCCF_SEQ_NUMBER_WRAP_ERROR ) + MQCONST2STR(MQRCCF_MAX_MSG_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_PUT_AUTH_ERROR ) + MQCONST2STR(MQRCCF_PURGE_VALUE_ERROR ) + MQCONST2STR(MQRCCF_CFIL_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_MSG_TRUNCATED ) + MQCONST2STR(MQRCCF_CCSID_ERROR ) + MQCONST2STR(MQRCCF_ENCODING_ERROR ) + MQCONST2STR(MQRCCF_QUEUES_VALUE_ERROR ) + MQCONST2STR(MQRCCF_DATA_CONV_VALUE_ERROR ) + MQCONST2STR(MQRCCF_INDOUBT_VALUE_ERROR ) + MQCONST2STR(MQRCCF_ESCAPE_TYPE_ERROR ) + MQCONST2STR(MQRCCF_REPOS_VALUE_ERROR ) + MQCONST2STR(MQRCCF_CHANNEL_TABLE_ERROR ) + MQCONST2STR(MQRCCF_MCA_TYPE_ERROR ) + MQCONST2STR(MQRCCF_CHL_INST_TYPE_ERROR ) + MQCONST2STR(MQRCCF_CHL_STATUS_NOT_FOUND ) + MQCONST2STR(MQRCCF_CFSL_DUPLICATE_PARM ) + MQCONST2STR(MQRCCF_CFSL_TOTAL_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFSL_COUNT_ERROR ) + MQCONST2STR(MQRCCF_CFSL_STRING_LENGTH_ERR ) + MQCONST2STR(MQRCCF_BROKER_DELETED ) + MQCONST2STR(MQRCCF_STREAM_ERROR ) + MQCONST2STR(MQRCCF_TOPIC_ERROR ) + MQCONST2STR(MQRCCF_NOT_REGISTERED ) + MQCONST2STR(MQRCCF_Q_MGR_NAME_ERROR ) + MQCONST2STR(MQRCCF_INCORRECT_STREAM ) + MQCONST2STR(MQRCCF_Q_NAME_ERROR ) + MQCONST2STR(MQRCCF_NO_RETAINED_MSG ) + MQCONST2STR(MQRCCF_DUPLICATE_IDENTITY ) + MQCONST2STR(MQRCCF_INCORRECT_Q ) + MQCONST2STR(MQRCCF_CORREL_ID_ERROR ) + MQCONST2STR(MQRCCF_NOT_AUTHORIZED ) + MQCONST2STR(MQRCCF_UNKNOWN_STREAM ) + MQCONST2STR(MQRCCF_REG_OPTIONS_ERROR ) + MQCONST2STR(MQRCCF_PUB_OPTIONS_ERROR ) + MQCONST2STR(MQRCCF_UNKNOWN_BROKER ) + MQCONST2STR(MQRCCF_Q_MGR_CCSID_ERROR ) + MQCONST2STR(MQRCCF_DEL_OPTIONS_ERROR ) + MQCONST2STR(MQRCCF_CLUSTER_NAME_CONFLICT ) + MQCONST2STR(MQRCCF_REPOS_NAME_CONFLICT ) + MQCONST2STR(MQRCCF_CLUSTER_Q_USAGE_ERROR ) + MQCONST2STR(MQRCCF_ACTION_VALUE_ERROR ) + MQCONST2STR(MQRCCF_COMMS_LIBRARY_ERROR ) + MQCONST2STR(MQRCCF_NETBIOS_NAME_ERROR ) + MQCONST2STR(MQRCCF_BROKER_COMMAND_FAILED ) + MQCONST2STR(MQRCCF_CFST_CONFLICTING_PARM ) + MQCONST2STR(MQRCCF_PATH_NOT_VALID ) + MQCONST2STR(MQRCCF_PARM_SYNTAX_ERROR ) + MQCONST2STR(MQRCCF_PWD_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_FILTER_ERROR ) + MQCONST2STR(MQRCCF_WRONG_USER ) + MQCONST2STR(MQRCCF_DUPLICATE_SUBSCRIPTION ) + MQCONST2STR(MQRCCF_SUB_NAME_ERROR ) + MQCONST2STR(MQRCCF_SUB_IDENTITY_ERROR ) + MQCONST2STR(MQRCCF_SUBSCRIPTION_IN_USE ) + MQCONST2STR(MQRCCF_SUBSCRIPTION_LOCKED ) + MQCONST2STR(MQRCCF_ALREADY_JOINED ) + MQCONST2STR(MQRCCF_OBJECT_IN_USE ) + MQCONST2STR(MQRCCF_UNKNOWN_FILE_NAME ) + MQCONST2STR(MQRCCF_FILE_NOT_AVAILABLE ) + MQCONST2STR(MQRCCF_DISC_RETRY_ERROR ) + MQCONST2STR(MQRCCF_ALLOC_RETRY_ERROR ) + MQCONST2STR(MQRCCF_ALLOC_SLOW_TIMER_ERROR ) + MQCONST2STR(MQRCCF_ALLOC_FAST_TIMER_ERROR ) + MQCONST2STR(MQRCCF_PORT_NUMBER_ERROR ) + MQCONST2STR(MQRCCF_CHL_SYSTEM_NOT_ACTIVE ) + MQCONST2STR(MQRCCF_ENTITY_NAME_MISSING ) + MQCONST2STR(MQRCCF_PROFILE_NAME_ERROR ) + MQCONST2STR(MQRCCF_AUTH_VALUE_ERROR ) + MQCONST2STR(MQRCCF_AUTH_VALUE_MISSING ) + MQCONST2STR(MQRCCF_OBJECT_TYPE_MISSING ) + MQCONST2STR(MQRCCF_CONNECTION_ID_ERROR ) + MQCONST2STR(MQRCCF_LOG_TYPE_ERROR ) + MQCONST2STR(MQRCCF_PROGRAM_NOT_AVAILABLE ) + MQCONST2STR(MQRCCF_PROGRAM_AUTH_FAILED ) + MQCONST2STR(MQRCCF_NONE_FOUND ) + MQCONST2STR(MQRCCF_SECURITY_SWITCH_OFF ) + MQCONST2STR(MQRCCF_SECURITY_REFRESH_FAILED ) + MQCONST2STR(MQRCCF_PARM_CONFLICT ) + MQCONST2STR(MQRCCF_COMMAND_INHIBITED ) + MQCONST2STR(MQRCCF_OBJECT_BEING_DELETED ) + MQCONST2STR(MQRCCF_STORAGE_CLASS_IN_USE ) + MQCONST2STR(MQRCCF_OBJECT_NAME_RESTRICTED ) + MQCONST2STR(MQRCCF_OBJECT_LIMIT_EXCEEDED ) + MQCONST2STR(MQRCCF_OBJECT_OPEN_FORCE ) + MQCONST2STR(MQRCCF_DISPOSITION_CONFLICT ) + MQCONST2STR(MQRCCF_Q_MGR_NOT_IN_QSG ) + MQCONST2STR(MQRCCF_ATTR_VALUE_FIXED ) + MQCONST2STR(MQRCCF_NAMELIST_ERROR ) + MQCONST2STR(MQRCCF_NO_CHANNEL_INITIATOR ) + MQCONST2STR(MQRCCF_CHANNEL_INITIATOR_ERROR ) + MQCONST2STR(MQRCCF_COMMAND_LEVEL_CONFLICT ) + MQCONST2STR(MQRCCF_Q_ATTR_CONFLICT ) + MQCONST2STR(MQRCCF_EVENTS_DISABLED ) + MQCONST2STR(MQRCCF_COMMAND_SCOPE_ERROR ) + MQCONST2STR(MQRCCF_COMMAND_REPLY_ERROR ) + MQCONST2STR(MQRCCF_FUNCTION_RESTRICTED ) + MQCONST2STR(MQRCCF_PARM_MISSING ) + MQCONST2STR(MQRCCF_PARM_VALUE_ERROR ) + MQCONST2STR(MQRCCF_COMMAND_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_COMMAND_ORIGIN_ERROR ) + MQCONST2STR(MQRCCF_LISTENER_CONFLICT ) + MQCONST2STR(MQRCCF_LISTENER_STARTED ) + MQCONST2STR(MQRCCF_LISTENER_STOPPED ) + MQCONST2STR(MQRCCF_CHANNEL_ERROR ) + MQCONST2STR(MQRCCF_CF_STRUC_ERROR ) + MQCONST2STR(MQRCCF_UNKNOWN_USER_ID ) + MQCONST2STR(MQRCCF_UNEXPECTED_ERROR ) + MQCONST2STR(MQRCCF_NO_XCF_PARTNER ) + MQCONST2STR(MQRCCF_CFGR_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_CFIF_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFIF_OPERATOR_ERROR ) + MQCONST2STR(MQRCCF_CFIF_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_CFSF_FILTER_VAL_LEN_ERR ) + MQCONST2STR(MQRCCF_CFSF_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFSF_OPERATOR_ERROR ) + MQCONST2STR(MQRCCF_CFSF_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_TOO_MANY_FILTERS ) + MQCONST2STR(MQRCCF_LISTENER_RUNNING ) + MQCONST2STR(MQRCCF_LSTR_STATUS_NOT_FOUND ) + MQCONST2STR(MQRCCF_SERVICE_RUNNING ) + MQCONST2STR(MQRCCF_SERV_STATUS_NOT_FOUND ) + MQCONST2STR(MQRCCF_SERVICE_STOPPED ) + MQCONST2STR(MQRCCF_CFBS_DUPLICATE_PARM ) + MQCONST2STR(MQRCCF_CFBS_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFBS_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_CFBS_STRING_LENGTH_ERR ) + MQCONST2STR(MQRCCF_CFGR_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFGR_PARM_COUNT_ERROR ) + MQCONST2STR(MQRCCF_CONN_NOT_STOPPED ) + MQCONST2STR(MQRCCF_SERVICE_REQUEST_PENDING ) + MQCONST2STR(MQRCCF_NO_START_CMD ) + MQCONST2STR(MQRCCF_NO_STOP_CMD ) + MQCONST2STR(MQRCCF_CFBF_LENGTH_ERROR ) + MQCONST2STR(MQRCCF_CFBF_PARM_ID_ERROR ) + MQCONST2STR(MQRCCF_CFBF_OPERATOR_ERROR ) + MQCONST2STR(MQRCCF_CFBF_FILTER_VAL_LEN_ERR ) + MQCONST2STR(MQRCCF_LISTENER_STILL_ACTIVE ) + MQCONST2STR(MQRCCF_DEF_XMIT_Q_CLUS_ERROR ) + MQCONST2STR(MQRCCF_TOPICSTR_ALREADY_EXISTS ) + MQCONST2STR(MQRCCF_SHARING_CONVS_ERROR ) + MQCONST2STR(MQRCCF_SHARING_CONVS_TYPE ) + MQCONST2STR(MQRCCF_SECURITY_CASE_CONFLICT ) + MQCONST2STR(MQRCCF_TOPIC_TYPE_ERROR ) + MQCONST2STR(MQRCCF_MAX_INSTANCES_ERROR ) + MQCONST2STR(MQRCCF_MAX_INSTS_PER_CLNT_ERR ) + MQCONST2STR(MQRCCF_TOPIC_STRING_NOT_FOUND ) + MQCONST2STR(MQRCCF_SUBSCRIPTION_POINT_ERR ) + MQCONST2STR(MQRCCF_SUB_ALREADY_EXISTS ) + MQCONST2STR(MQRCCF_UNKNOWN_OBJECT_NAME ) + MQCONST2STR(MQRCCF_REMOTE_Q_NAME_ERROR ) + MQCONST2STR(MQRCCF_DURABILITY_NOT_ALLOWED ) + MQCONST2STR(MQRCCF_HOBJ_ERROR ) + MQCONST2STR(MQRCCF_DEST_NAME_ERROR ) + MQCONST2STR(MQRCCF_INVALID_DESTINATION ) + MQCONST2STR(MQRCCF_PUBSUB_INHIBITED ) + MQCONST2STR(MQRCCF_GROUPUR_CHECKS_FAILED ) + MQCONST2STR(MQRCCF_COMM_INFO_TYPE_ERROR ) + MQCONST2STR(MQRCCF_USE_CLIENT_ID_ERROR ) + MQCONST2STR(MQRCCF_CLIENT_ID_NOT_FOUND ) + MQCONST2STR(MQRCCF_CLIENT_ID_ERROR ) + MQCONST2STR(MQRCCF_PORT_IN_USE ) + MQCONST2STR(MQRCCF_SSL_ALT_PROVIDER_REQD ) + MQCONST2STR(MQRCCF_CHLAUTH_TYPE_ERROR ) + MQCONST2STR(MQRCCF_CHLAUTH_ACTION_ERROR ) + MQCONST2STR(MQRCCF_POLICY_NOT_FOUND ) + MQCONST2STR(MQRCCF_ENCRYPTION_ALG_ERROR ) + MQCONST2STR(MQRCCF_SIGNATURE_ALG_ERROR ) + MQCONST2STR(MQRCCF_TOLERATION_POL_ERROR ) + MQCONST2STR(MQRCCF_POLICY_VERSION_ERROR ) + MQCONST2STR(MQRCCF_RECIPIENT_DN_MISSING ) + MQCONST2STR(MQRCCF_POLICY_NAME_MISSING ) + MQCONST2STR(MQRCCF_CHLAUTH_USERSRC_ERROR ) + MQCONST2STR(MQRCCF_WRONG_CHLAUTH_TYPE ) + MQCONST2STR(MQRCCF_CHLAUTH_ALREADY_EXISTS ) + MQCONST2STR(MQRCCF_CHLAUTH_NOT_FOUND ) + MQCONST2STR(MQRCCF_WRONG_CHLAUTH_ACTION ) + MQCONST2STR(MQRCCF_WRONG_CHLAUTH_USERSRC ) + MQCONST2STR(MQRCCF_CHLAUTH_WARN_ERROR ) + MQCONST2STR(MQRCCF_WRONG_CHLAUTH_MATCH ) + MQCONST2STR(MQRCCF_IPADDR_RANGE_CONFLICT ) + MQCONST2STR(MQRCCF_CHLAUTH_MAX_EXCEEDED ) + MQCONST2STR(MQRCCF_IPADDR_ERROR ) + MQCONST2STR(MQRCCF_IPADDR_RANGE_ERROR ) + MQCONST2STR(MQRCCF_PROFILE_NAME_MISSING ) + MQCONST2STR(MQRCCF_CHLAUTH_CLNTUSER_ERROR ) + MQCONST2STR(MQRCCF_CHLAUTH_NAME_ERROR ) + MQCONST2STR(MQRCCF_CHLAUTH_RUNCHECK_ERROR ) + MQCONST2STR(MQRCCF_CF_STRUC_ALREADY_FAILED ) + MQCONST2STR(MQRCCF_CFCONLOS_CHECKS_FAILED ) + MQCONST2STR(MQRCCF_SUITE_B_ERROR ) + MQCONST2STR(MQRCCF_CHANNEL_NOT_STARTED ) + MQCONST2STR(MQRCCF_CUSTOM_ERROR ) + MQCONST2STR(MQRCCF_BACKLOG_OUT_OF_RANGE ) + MQCONST2STR(MQRCCF_CHLAUTH_DISABLED ) + MQCONST2STR(MQRCCF_SMDS_REQUIRES_DSGROUP ) + MQCONST2STR(MQRCCF_PSCLUS_DISABLED_TOPDEF ) + MQCONST2STR(MQRCCF_PSCLUS_TOPIC_EXISTS ) + MQCONST2STR(MQRCCF_SSL_CIPHER_SUITE_ERROR ) + MQCONST2STR(MQRCCF_SOCKET_ERROR ) +#ifdef MQRCCF_CLUS_XMIT_Q_USAGE_ERROR + MQCONST2STR(MQRCCF_CLUS_XMIT_Q_USAGE_ERROR ) +#endif +#ifdef MQRCCF_CERT_VAL_POLICY_ERROR + MQCONST2STR(MQRCCF_CERT_VAL_POLICY_ERROR ) +#endif + + // C++ Reason codes MQCONST2STR(MQRC_REOPEN_EXCL_INPUT_ERROR ) MQCONST2STR(MQRC_REOPEN_INQUIRE_ERROR ) MQCONST2STR(MQRC_REOPEN_SAVED_CONTEXT_ERR ) From fd260745816fdf80c51bf87040a84f427b38fb9e Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 5 Sep 2014 19:12:20 +0200 Subject: [PATCH 046/143] Don't set AuthInfoAttrs when no attributes parameter is passed --- MQWeb/src/AuthenticationInformationController.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/MQWeb/src/AuthenticationInformationController.cpp b/MQWeb/src/AuthenticationInformationController.cpp index d0c38a7..1d45d2f 100644 --- a/MQWeb/src/AuthenticationInformationController.cpp +++ b/MQWeb/src/AuthenticationInformationController.cpp @@ -78,7 +78,6 @@ void AuthenticationInformationController::inquire() } Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); - pcfParameters->set("AuthInfoAttrs", attrs); formElementToJSONArray("AuthInfoAttrs", attrs); if ( attrs->size() == 0 ) // Nothing found for AuthInfoAttrs, try Attrs { From 27b3ed432afa418857914ffbed48e6f206e579ff Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 5 Sep 2014 19:14:08 +0200 Subject: [PATCH 047/143] Update for using JSON filter --- MQWeb/src/AuthorityRecordController.cpp | 81 ++++++++++++++++++------- 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/MQWeb/src/AuthorityRecordController.cpp b/MQWeb/src/AuthorityRecordController.cpp index 3914eb8..0ae2fc4 100644 --- a/MQWeb/src/AuthorityRecordController.cpp +++ b/MQWeb/src/AuthorityRecordController.cpp @@ -40,38 +40,73 @@ AuthorityRecordController::~AuthorityRecordController() void AuthorityRecordController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + if ( qmgr()->zos() ) + { + // Authority records are not supported on z/OS + setResponseStatus(Poco::Net::HTTPResponse::HTTP_NOT_IMPLEMENTED, "/authrec/inquire not implemented for z/OS"); + return; + } + + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a authentication information name and will result in inquiring - // only that queue and ignores all query parameters. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("profileName", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - // Handle query parameters - if ( form().has("profileName") ) filter->set("profileName", form().get("profileName")); - } + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); - Poco::JSON::Array::Ptr jsonOptions = new Poco::JSON::Array(); - filter->set("options", jsonOptions); - for(Poco::Net::NameValueCollection::ConstIterator itOptions = form().find("options"); - itOptions != form().end() && itOptions->first == "options"; - ++itOptions) - { - jsonOptions->add(itOptions->second); - } + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a authentication information name and will result in inquiring + // only that queue and ignores all query parameters. + if ( parameters.size() > 1 ) + { + pcfParameters->set("ProfileName", parameters[1]); + } + else + { + // Handle query parameters + if ( form().has("ProfileName") ) + { + pcfParameters->set("ProfileName", form().get("ProfileName")); + } + else if ( form().has("Name") ) + { + pcfParameters->set("ProfileName", form().get("Name")); + } + } + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("ProfileAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ProfileAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ProfileAttrs", attrs); + } - if ( form().has("objectType") ) filter->set("objectType", form().get("objectType")); - if ( form().has("entityName") ) filter->set("entityName", form().get("entityName")); - if ( form().has("entityType") ) filter->set("entityType", form().get("entityType")); - if ( form().has("serviceComponent") ) filter->set("serviceComponent", form().get("serviceComponent")); + Poco::JSON::Array::Ptr jsonOptions = new Poco::JSON::Array(); + pcfParameters->set("Options", jsonOptions); + for(Poco::Net::NameValueCollection::ConstIterator itOptions = form().find("Options"); + itOptions != form().end() && itOptions->first == "Options"; + ++itOptions) + { + jsonOptions->add(itOptions->second); + } + + if ( form().has("ObjectType") ) pcfParameters->set("ObjectType", form().get("ObjectType")); + if ( form().has("EntityName") ) pcfParameters->set("EntityName", form().get("EntityName")); + if ( form().has("EntityType") ) pcfParameters->set("EntityType", form().get("EntityType")); + if ( form().has("ServiceComponent") ) pcfParameters->set("ServiceComponent", form().get("ServiceComponent")); + } AuthorityRecordMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(filter); + Poco::JSON::Array::Ptr json = mapper.inquire(pcfParameters); set("authrecs", json); } From 71f59d482a91e4ad511665102d25a4fa622e59b0 Mon Sep 17 00:00:00 2001 From: fbraem Date: Sun, 7 Sep 2014 17:25:52 +0200 Subject: [PATCH 048/143] Use Poco::icompare for looping options --- MQWeb/src/AuthorityRecordController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQWeb/src/AuthorityRecordController.cpp b/MQWeb/src/AuthorityRecordController.cpp index 0ae2fc4..79fc5a7 100644 --- a/MQWeb/src/AuthorityRecordController.cpp +++ b/MQWeb/src/AuthorityRecordController.cpp @@ -93,7 +93,7 @@ void AuthorityRecordController::inquire() Poco::JSON::Array::Ptr jsonOptions = new Poco::JSON::Array(); pcfParameters->set("Options", jsonOptions); for(Poco::Net::NameValueCollection::ConstIterator itOptions = form().find("Options"); - itOptions != form().end() && itOptions->first == "Options"; + itOptions != form().end() && Poco::icompare(itOptions->first, "Options") == 0; ++itOptions) { jsonOptions->add(itOptions->second); From 80d4a245ddd005e9d54e765164b63cc8f88d9cf4 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Wed, 10 Sep 2014 10:29:11 +0200 Subject: [PATCH 049/143] Required pcf parameters must be specified in the same order as stated in the reference --- MQWeb/src/AuthorityRecordMapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MQWeb/src/AuthorityRecordMapper.cpp b/MQWeb/src/AuthorityRecordMapper.cpp index 5e86fa9..02fa7e3 100644 --- a/MQWeb/src/AuthorityRecordMapper.cpp +++ b/MQWeb/src/AuthorityRecordMapper.cpp @@ -57,7 +57,6 @@ Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire(const Poco::JSON::Object:: Command command(this, MQCMD_INQUIRE_AUTH_RECS, filter); // Required parameters - command.addParameter(MQCACF_AUTH_PROFILE_NAME, "ProfileName"); MQLONG options = 0; Poco::JSON::Array::Ptr optionsValue = filter->getArray("Options"); @@ -87,8 +86,9 @@ Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire(const Poco::JSON::Object:: options |= MQAUTHOPT_NAME_AS_WILDCARD; } } + command.pcf()->addParameter(MQIACF_AUTH_OPTIONS, options); } - command.pcf()->addParameter(MQIACF_AUTH_OPTIONS, options); + command.addParameter(MQCACF_AUTH_PROFILE_NAME, "ProfileName"); command.addParameterNumFromString(MQIACF_OBJECT_TYPE, "ObjectType"); From abac75db1151767781ddb3010615ff0ca2a81540 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Wed, 10 Sep 2014 10:36:34 +0200 Subject: [PATCH 050/143] Don't throw PFC exception for MQRCCF_NONE_FOUND --- MQWeb/src/MQMapper.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index 2f71ce9..607b0ef 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -197,7 +197,10 @@ void MQMapper::Command::execute(PCF::Vector& response) if ( response.size() > 0 ) { PCF::Vector::const_iterator it = response.begin(); - if ( (*it)->getCompletionCode() == MQCC_FAILED && (*it)->getReasonCode() > 3000 && (*it)->getReasonCode() < 4000 ) + if ( (*it)->getCompletionCode() == MQCC_FAILED + && (*it)->getReasonCode() > 3000 + && (*it)->getReasonCode() < 4000 + && (*it)->getReasonCode() != MQRCCF_NONE_FOUND ) { static Poco::SharedPtr dict = _dictionaryCache.getDictionary("Event"); std::string command = dict->getDisplayValue(MQIACF_COMMAND, (*it)->getCommand()); From 289c5759084c1ae184826495702f45095170336c Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 11 Sep 2014 18:40:09 +0200 Subject: [PATCH 051/143] Reorganized MQMapper --- .../MQ/Web/AuthenticationInformationMapper.h | 10 +-- MQWeb/include/MQ/Web/AuthorityRecordMapper.h | 10 +-- MQWeb/include/MQ/Web/ChannelMapper.h | 10 +-- MQWeb/include/MQ/Web/ChannelStatusMapper.h | 10 +-- .../MQ/Web/ClusterQueueManagerMapper.h | 10 +-- MQWeb/include/MQ/Web/ConnectionMapper.h | 10 +-- MQWeb/include/MQ/Web/ListenerMapper.h | 10 +-- MQWeb/include/MQ/Web/ListenerStatusMapper.h | 10 +-- MQWeb/include/MQ/Web/MQMapper.h | 78 +++++++++---------- MQWeb/include/MQ/Web/Mapper.h | 8 +- MQWeb/include/MQ/Web/NamelistMapper.h | 10 +-- MQWeb/include/MQ/Web/ProcessMapper.h | 10 +-- MQWeb/include/MQ/Web/QueueManagerMapper.h | 10 +-- .../include/MQ/Web/QueueManagerStatusMapper.h | 10 +-- MQWeb/include/MQ/Web/QueueMapper.h | 10 +-- MQWeb/include/MQ/Web/QueueStatusMapper.h | 10 +-- MQWeb/include/MQ/Web/ServiceMapper.h | 10 +-- .../AuthenticationInformationController.cpp | 6 +- MQWeb/src/AuthenticationInformationMapper.cpp | 44 +++++------ MQWeb/src/AuthorityRecordController.cpp | 6 +- MQWeb/src/AuthorityRecordMapper.cpp | 41 +++++----- MQWeb/src/ChannelController.cpp | 7 +- MQWeb/src/ChannelMapper.cpp | 45 +++++------ MQWeb/src/ChannelStatusController.cpp | 7 +- MQWeb/src/ChannelStatusMapper.cpp | 50 ++++++------ MQWeb/src/ClusterQueueManagerController.cpp | 6 +- MQWeb/src/ClusterQueueManagerMapper.cpp | 43 +++++----- MQWeb/src/ConnectionController.cpp | 6 +- MQWeb/src/ConnectionMapper.cpp | 48 +++++------- MQWeb/src/ListenerController.cpp | 6 +- MQWeb/src/ListenerMapper.cpp | 40 ++++------ MQWeb/src/ListenerStatusController.cpp | 6 +- MQWeb/src/ListenerStatusMapper.cpp | 32 ++++---- MQWeb/src/MQMapper.cpp | 63 ++++++++------- MQWeb/src/NamelistController.cpp | 6 +- MQWeb/src/NamelistMapper.cpp | 43 +++++----- MQWeb/src/ProcessController.cpp | 6 +- MQWeb/src/ProcessMapper.cpp | 43 +++++----- MQWeb/src/QueueController.cpp | 7 +- MQWeb/src/QueueManagerController.cpp | 11 +-- MQWeb/src/QueueManagerMapper.cpp | 33 ++++---- MQWeb/src/QueueManagerStatusController.cpp | 11 +-- MQWeb/src/QueueManagerStatusMapper.cpp | 29 +++---- MQWeb/src/QueueMapper.cpp | 64 +++++++-------- MQWeb/src/QueueStatusController.cpp | 6 +- MQWeb/src/QueueStatusMapper.cpp | 48 +++++------- MQWeb/src/ServiceController.cpp | 5 +- MQWeb/src/ServiceMapper.cpp | 39 ++++------ 48 files changed, 457 insertions(+), 586 deletions(-) diff --git a/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h b/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h index 93415e0..310c238 100644 --- a/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h +++ b/MQWeb/include/MQ/Web/AuthenticationInformationMapper.h @@ -31,22 +31,22 @@ class AuthenticationInformationMapper : public MQMapper { public: - AuthenticationInformationMapper(CommandServer& commandServer); + AuthenticationInformationMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~AuthenticationInformationMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change authentication information command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create authentication information command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy authentication information command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire authentication information command. private: diff --git a/MQWeb/include/MQ/Web/AuthorityRecordMapper.h b/MQWeb/include/MQ/Web/AuthorityRecordMapper.h index 81e54da..b4aec17 100644 --- a/MQWeb/include/MQ/Web/AuthorityRecordMapper.h +++ b/MQWeb/include/MQ/Web/AuthorityRecordMapper.h @@ -31,22 +31,22 @@ class AuthorityRecordMapper : public MQMapper { public: - AuthorityRecordMapper(CommandServer& commandServer); + AuthorityRecordMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~AuthorityRecordMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change authority records command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create authority records command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy authority records command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire authority records command. private: diff --git a/MQWeb/include/MQ/Web/ChannelMapper.h b/MQWeb/include/MQ/Web/ChannelMapper.h index 3b15625..29fe8c1 100644 --- a/MQWeb/include/MQ/Web/ChannelMapper.h +++ b/MQWeb/include/MQ/Web/ChannelMapper.h @@ -31,22 +31,22 @@ class ChannelMapper : public MQMapper { public: - ChannelMapper(CommandServer& commandServer); + ChannelMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~ChannelMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change channel command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create channel command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy channel command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire channel command. private: diff --git a/MQWeb/include/MQ/Web/ChannelStatusMapper.h b/MQWeb/include/MQ/Web/ChannelStatusMapper.h index ff025b9..dfcb0da 100644 --- a/MQWeb/include/MQ/Web/ChannelStatusMapper.h +++ b/MQWeb/include/MQ/Web/ChannelStatusMapper.h @@ -33,22 +33,22 @@ class ChannelStatusMapper : public MQMapper { public: - ChannelStatusMapper(CommandServer& commandServer); + ChannelStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~ChannelStatusMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Not implemented. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Not implemented - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Not implemented - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire channel status command. private: diff --git a/MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h b/MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h index 532a577..734470e 100644 --- a/MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h +++ b/MQWeb/include/MQ/Web/ClusterQueueManagerMapper.h @@ -31,22 +31,22 @@ class ClusterQueueManagerMapper : public MQMapper { public: - ClusterQueueManagerMapper(CommandServer& commandServer); + ClusterQueueManagerMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~ClusterQueueManagerMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Not implemented. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Not implemented. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Not implemented. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire cluster qmgr command. private: diff --git a/MQWeb/include/MQ/Web/ConnectionMapper.h b/MQWeb/include/MQ/Web/ConnectionMapper.h index 5421fe9..e2614d0 100644 --- a/MQWeb/include/MQ/Web/ConnectionMapper.h +++ b/MQWeb/include/MQ/Web/ConnectionMapper.h @@ -31,22 +31,22 @@ class ConnectionMapper : public MQMapper { public: - ConnectionMapper(CommandServer& commandServer); + ConnectionMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~ConnectionMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Not implemented. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Not implemented. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Not implemented. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire connection command. private: diff --git a/MQWeb/include/MQ/Web/ListenerMapper.h b/MQWeb/include/MQ/Web/ListenerMapper.h index 65ac776..8273bdf 100644 --- a/MQWeb/include/MQ/Web/ListenerMapper.h +++ b/MQWeb/include/MQ/Web/ListenerMapper.h @@ -31,22 +31,22 @@ class ListenerMapper : public MQMapper { public: - ListenerMapper(CommandServer& commandServer); + ListenerMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~ListenerMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change listener command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create listener command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy listener command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire listener command. private: diff --git a/MQWeb/include/MQ/Web/ListenerStatusMapper.h b/MQWeb/include/MQ/Web/ListenerStatusMapper.h index 6c1b534..9910d2a 100644 --- a/MQWeb/include/MQ/Web/ListenerStatusMapper.h +++ b/MQWeb/include/MQ/Web/ListenerStatusMapper.h @@ -31,22 +31,22 @@ class ListenerStatusMapper : public MQMapper { public: - ListenerStatusMapper(CommandServer& commandServer); + ListenerStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~ListenerStatusMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change listener command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create listener command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy listener command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire listener command. private: diff --git a/MQWeb/include/MQ/Web/MQMapper.h b/MQWeb/include/MQ/Web/MQMapper.h index e050194..e10e84c 100644 --- a/MQWeb/include/MQ/Web/MQMapper.h +++ b/MQWeb/include/MQ/Web/MQMapper.h @@ -36,16 +36,13 @@ class MQMapper : public Mapper /// It uses the Dictionary class for holding all Websphere MQ fields/values. { public: - MQMapper(CommandServer& commandServer, const std::string& objectType); + MQMapper(CommandServer& commandServer, const std::string& objectType, Poco::JSON::Object::Ptr input); /// Constructor virtual ~MQMapper(); /// Destructor - const CommandServer& commandServer() const; - /// Returns the associated commandserver - - const Poco::SharedPtr dictionary() const; + //const Poco::SharedPtr dictionary() const; /// Returns the dictionary for the associated object type static MQLONG getOperator(const std::string& op); @@ -62,57 +59,48 @@ class MQMapper : public Mapper protected: - class Command - { - public: - Command(MQMapper* mapper, MQLONG command, Poco::JSON::Object::Ptr filter); - - virtual ~Command(); - - void addAttributeList(MQLONG attrId, const std::string& attr); - /// Handles the attribute list - - void addIntegerFilter(); - /// When IntegerFilterCommand is set, it will add an integer filter to the PCF message + void createCommand(MQLONG command); - template - void addParameter(MQLONG parameter, const std::string& name); + Poco::JSON::Object::Ptr createJSON(const PCF& pcf); - void addParameterNumFromString(MQLONG parameter, const std::string& name); + void addAttributeList(MQLONG attrId, const std::string& attr); + /// Handles the attribute list - void addStringFilter(); - /// When StringFilterCommand is set, it will add an string filter to the PCF message + void addIntegerFilter(); + /// When IntegerFilterCommand is set, it will add an integer filter to the PCF message - void execute(PCF::Vector& response); - /// Sends the PCF command to the command server + template + void addParameter(MQLONG parameter, const std::string& name); - PCF::Ptr pcf(); - /// Returns the PCF command message + void addParameterNumFromString(MQLONG parameter, const std::string& name); - private: + void addStringFilter(); + /// When StringFilterCommand is set, it will add an string filter to the PCF message - MQMapper* _mapper; + void execute(PCF::Vector& response); + /// Sends the PCF command to the command server - PCF::Ptr _pcf; + PCF::Ptr pcf(); - Poco::JSON::Object::Ptr _filter; - }; + Poco::JSON::Object::Ptr _input; private: CommandServer& _commandServer; - Poco::SharedPtr _dictionary; - static DictionaryCache _dictionaryCache; + + PCF::Ptr _pcf; }; template -inline void MQMapper::Command::addParameter(MQLONG parameter, const std::string& name) +inline void MQMapper::addParameter(MQLONG parameter, const std::string& name) { - Poco::Dynamic::Var value = _filter->get(name); + poco_assert_dbg(!_pcf.isNull()); + + Poco::Dynamic::Var value = _input->get(name); if (! value.isEmpty() ) { try @@ -125,15 +113,18 @@ inline void MQMapper::Command::addParameter(MQLONG parameter, const std::string& } } } - -inline const CommandServer& MQMapper::commandServer() const +/* +inline const Poco::SharedPtr MQMapper::dictionary() const { - return _commandServer; + return _dictionary; } +*/ -inline const Poco::SharedPtr MQMapper::dictionary() const +inline Poco::JSON::Object::Ptr MQMapper::createJSON(const PCF &pcf) { - return _dictionary; + Poco::JSON::Object::Ptr json = new Poco::JSON::Object(); + _dictionary->mapToJSON(pcf, json); + return json; } inline const Poco::SharedPtr MQMapper::dictionary(const std::string& objectType) @@ -141,7 +132,12 @@ inline const Poco::SharedPtr MQMapper::dictionary(const std::string& return _dictionaryCache.getDictionary(objectType); } -inline PCF::Ptr MQMapper::Command::pcf() +inline void MQMapper::createCommand(MQLONG command) +{ + _pcf = _commandServer.createCommand(command); +} + +inline PCF::Ptr MQMapper::pcf() { return _pcf; } diff --git a/MQWeb/include/MQ/Web/Mapper.h b/MQWeb/include/MQ/Web/Mapper.h index 4ae4915..4e764be 100644 --- a/MQWeb/include/MQ/Web/Mapper.h +++ b/MQWeb/include/MQ/Web/Mapper.h @@ -32,16 +32,16 @@ class Mapper { public: - virtual void change(const Poco::JSON::Object::Ptr&obj) = 0; + virtual void change() = 0; - virtual void create(const Poco::JSON::Object::Ptr& obj, bool replace = false) = 0; + virtual void create(bool replace = false) = 0; - virtual void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false) = 0; + virtual void copy(bool replace = false) = 0; - virtual Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter) = 0; + virtual Poco::JSON::Array::Ptr inquire() = 0; }; diff --git a/MQWeb/include/MQ/Web/NamelistMapper.h b/MQWeb/include/MQ/Web/NamelistMapper.h index f94c597..fd1a8c6 100644 --- a/MQWeb/include/MQ/Web/NamelistMapper.h +++ b/MQWeb/include/MQ/Web/NamelistMapper.h @@ -31,22 +31,22 @@ class NamelistMapper : public MQMapper { public: - NamelistMapper(CommandServer& commandServer); + NamelistMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~NamelistMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change namelist command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create namelist command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy namelist command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire namelist command. private: diff --git a/MQWeb/include/MQ/Web/ProcessMapper.h b/MQWeb/include/MQ/Web/ProcessMapper.h index 754f174..37fa3ff 100644 --- a/MQWeb/include/MQ/Web/ProcessMapper.h +++ b/MQWeb/include/MQ/Web/ProcessMapper.h @@ -31,22 +31,22 @@ class ProcessMapper : public MQMapper { public: - ProcessMapper(CommandServer& commandServer); + ProcessMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~ProcessMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change process command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create process command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy process command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire process command. private: diff --git a/MQWeb/include/MQ/Web/QueueManagerMapper.h b/MQWeb/include/MQ/Web/QueueManagerMapper.h index 085ebf9..399aaef 100644 --- a/MQWeb/include/MQ/Web/QueueManagerMapper.h +++ b/MQWeb/include/MQ/Web/QueueManagerMapper.h @@ -31,22 +31,22 @@ class QueueManagerMapper : public MQMapper { public: - QueueManagerMapper(CommandServer& commandServer); + QueueManagerMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~QueueManagerMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change queuemanager command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Not implemented. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Not implemented. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire queuemanager command. private: diff --git a/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h b/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h index 7d177d0..360142c 100644 --- a/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h +++ b/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h @@ -31,22 +31,22 @@ class QueueManagerStatusMapper : public MQMapper { public: - QueueManagerStatusMapper(CommandServer& commandServer); + QueueManagerStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~QueueManagerStatusMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Not implemented. Change QueueManager Status doesn't exist. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Not implemented. Create QueueManager Status doesn't exist. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Not implemented. Copy QueueManager Status doesn't exist. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the Inquire Queuemanager Status command. private: diff --git a/MQWeb/include/MQ/Web/QueueMapper.h b/MQWeb/include/MQ/Web/QueueMapper.h index d20496a..35066a4 100644 --- a/MQWeb/include/MQ/Web/QueueMapper.h +++ b/MQWeb/include/MQ/Web/QueueMapper.h @@ -31,22 +31,22 @@ class QueueMapper : public MQMapper { public: - QueueMapper(CommandServer& commandServer); + QueueMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~QueueMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change queue command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create queue command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy queue command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire queue command. private: diff --git a/MQWeb/include/MQ/Web/QueueStatusMapper.h b/MQWeb/include/MQ/Web/QueueStatusMapper.h index 2785ddc..60f2779 100644 --- a/MQWeb/include/MQ/Web/QueueStatusMapper.h +++ b/MQWeb/include/MQ/Web/QueueStatusMapper.h @@ -31,22 +31,22 @@ class QueueStatusMapper : public MQMapper { public: - QueueStatusMapper(CommandServer& commandServer); + QueueStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~QueueStatusMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Not available. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Not available. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Not available. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire queue status command. private: diff --git a/MQWeb/include/MQ/Web/ServiceMapper.h b/MQWeb/include/MQ/Web/ServiceMapper.h index 3a3bf59..41bf0bf 100644 --- a/MQWeb/include/MQ/Web/ServiceMapper.h +++ b/MQWeb/include/MQ/Web/ServiceMapper.h @@ -31,22 +31,22 @@ class ServiceMapper : public MQMapper { public: - ServiceMapper(CommandServer& commandServer); + ServiceMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); /// Constructor virtual ~ServiceMapper(); /// Destructor - void change(const Poco::JSON::Object::Ptr&obj); + void change(); /// Implements the change service command. Not implemented yet. - void create(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void create(bool replace = false); /// Implements the create service command. Not implemented yet. - void copy(const Poco::JSON::Object::Ptr& obj, bool replace = false); + void copy(bool replace = false); /// Implements the copy service command. Not implemented yet. - Poco::JSON::Array::Ptr inquire(const Poco::JSON::Object::Ptr& filter); + Poco::JSON::Array::Ptr inquire(); /// Implements the inquire service command. private: diff --git a/MQWeb/src/AuthenticationInformationController.cpp b/MQWeb/src/AuthenticationInformationController.cpp index 1d45d2f..d695d62 100644 --- a/MQWeb/src/AuthenticationInformationController.cpp +++ b/MQWeb/src/AuthenticationInformationController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/AuthenticationInformationController.h" #include "MQ/Web/AuthenticationInformationMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -108,9 +107,8 @@ void AuthenticationInformationController::inquire() handleFilterForm(pcfParameters); } - AuthenticationInformationMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(pcfParameters); - set("authinfos", json); + AuthenticationInformationMapper mapper(*commandServer(), pcfParameters); + set("authinfos", mapper.inquire()); } diff --git a/MQWeb/src/AuthenticationInformationMapper.cpp b/MQWeb/src/AuthenticationInformationMapper.cpp index 0bbb587..cde093a 100644 --- a/MQWeb/src/AuthenticationInformationMapper.cpp +++ b/MQWeb/src/AuthenticationInformationMapper.cpp @@ -19,13 +19,12 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/AuthenticationInformationMapper.h" -#include "MQ/Web/Dictionary.h" -#include "MQ/MQException.h" namespace MQ { namespace Web { -AuthenticationInformationMapper::AuthenticationInformationMapper(CommandServer& commandServer) : MQMapper(commandServer, "AuthenticationInformation") +AuthenticationInformationMapper::AuthenticationInformationMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "AuthenticationInformation", input) { } @@ -34,47 +33,45 @@ AuthenticationInformationMapper::~AuthenticationInformationMapper() } -void AuthenticationInformationMapper::change(const Poco::JSON::Object::Ptr&obj) +void AuthenticationInformationMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void AuthenticationInformationMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void AuthenticationInformationMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void AuthenticationInformationMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void AuthenticationInformationMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_AUTH_INFO, filter); + createCommand(MQCMD_INQUIRE_AUTH_INFO); // Required parameters - command.addParameter(MQCA_AUTH_INFO_NAME, "AuthInfoName"); + addParameter(MQCA_AUTH_INFO_NAME, "AuthInfoName"); // Optional parameters - command.addAttributeList(MQIACF_AUTH_INFO_ATTRS, "AuthInfoAttrs"); - command.addParameterNumFromString(MQIA_AUTH_INFO_TYPE, "AuthInfoType"); - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addIntegerFilter(); - command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); - command.addStringFilter(); + addAttributeList(MQIACF_AUTH_INFO_ATTRS, "AuthInfoAttrs"); + addParameterNumFromString(MQIA_AUTH_INFO_TYPE, "AuthInfoType"); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addIntegerFilter(); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addStringFilter(); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("ExcludeSystem", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); - Poco::JSON::Array::Ptr jsonAuthInfos = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { @@ -91,13 +88,10 @@ Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire(const Poco::JSON continue; } - Poco::JSON::Object::Ptr jsonAuthInfo = new Poco::JSON::Object(); - jsonAuthInfos->add(jsonAuthInfo); - - dictionary()->mapToJSON(**it, jsonAuthInfo); + json->add(createJSON(**it)); } - return jsonAuthInfos; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/AuthorityRecordController.cpp b/MQWeb/src/AuthorityRecordController.cpp index 79fc5a7..022a644 100644 --- a/MQWeb/src/AuthorityRecordController.cpp +++ b/MQWeb/src/AuthorityRecordController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/AuthorityRecordController.h" #include "MQ/Web/AuthorityRecordMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -105,9 +104,8 @@ void AuthorityRecordController::inquire() if ( form().has("ServiceComponent") ) pcfParameters->set("ServiceComponent", form().get("ServiceComponent")); } - AuthorityRecordMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(pcfParameters); - set("authrecs", json); + AuthorityRecordMapper mapper(*commandServer(), pcfParameters); + set("authrecs", mapper.inquire()); } diff --git a/MQWeb/src/AuthorityRecordMapper.cpp b/MQWeb/src/AuthorityRecordMapper.cpp index 02fa7e3..908099d 100644 --- a/MQWeb/src/AuthorityRecordMapper.cpp +++ b/MQWeb/src/AuthorityRecordMapper.cpp @@ -23,43 +23,42 @@ namespace MQ { namespace Web { -AuthorityRecordMapper::AuthorityRecordMapper(CommandServer& commandServer) : MQMapper(commandServer, "AuthorityRecord") +AuthorityRecordMapper::AuthorityRecordMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "AuthorityRecord", _input) { } + AuthorityRecordMapper::~AuthorityRecordMapper() { } -void AuthorityRecordMapper::change(const Poco::JSON::Object::Ptr&obj) +void AuthorityRecordMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void AuthorityRecordMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void AuthorityRecordMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void AuthorityRecordMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void AuthorityRecordMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_AUTH_RECS, filter); + createCommand(MQCMD_INQUIRE_AUTH_RECS); // Required parameters - MQLONG options = 0; - Poco::JSON::Array::Ptr optionsValue = filter->getArray("Options"); + Poco::JSON::Array::Ptr optionsValue = _input->getArray("Options"); if ( !optionsValue.isNull() ) { for(Poco::JSON::Array::ValueVec::const_iterator it = optionsValue->begin(); it != optionsValue->end(); ++it) @@ -86,20 +85,19 @@ Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire(const Poco::JSON::Object:: options |= MQAUTHOPT_NAME_AS_WILDCARD; } } - command.pcf()->addParameter(MQIACF_AUTH_OPTIONS, options); + pcf()->addParameter(MQIACF_AUTH_OPTIONS, options); } - command.addParameter(MQCACF_AUTH_PROFILE_NAME, "ProfileName"); - - command.addParameterNumFromString(MQIACF_OBJECT_TYPE, "ObjectType"); + addParameter(MQCACF_AUTH_PROFILE_NAME, "ProfileName"); + addParameterNumFromString(MQIACF_OBJECT_TYPE, "ObjectType"); // Optional parameters - command.addParameter(MQCACF_ENTITY_NAME, "EntityName"); - command.addParameterNumFromString(MQIACF_ENTITY_TYPE, "EntityType"); - command.addAttributeList(MQIACF_AUTH_PROFILE_ATTRS, "ProfileAttrs"); - command.addParameter(MQCACF_SERVICE_COMPONENT, "ServiceComponent"); + addParameter(MQCACF_ENTITY_NAME, "EntityName"); + addParameterNumFromString(MQIACF_ENTITY_TYPE, "EntityType"); + addAttributeList(MQIACF_AUTH_PROFILE_ATTRS, "ProfileAttrs"); + addParameter(MQCACF_SERVICE_COMPONENT, "ServiceComponent"); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); @@ -111,10 +109,7 @@ Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire(const Poco::JSON::Object:: if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) continue; - Poco::JSON::Object::Ptr object = new Poco::JSON::Object(); - json->add(object); - - dictionary()->mapToJSON(**it, object); + json->add(createJSON(**it)); } return json; diff --git a/MQWeb/src/ChannelController.cpp b/MQWeb/src/ChannelController.cpp index abd0445..89cce87 100644 --- a/MQWeb/src/ChannelController.cpp +++ b/MQWeb/src/ChannelController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/ChannelController.h" #include "MQ/Web/ChannelMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -95,10 +94,8 @@ void ChannelController::inquire() } } - ChannelMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr channels = mapper.inquire(pcfParameters); - set("channels", channels); - setView(new JSONView()); + ChannelMapper mapper(*commandServer(), pcfParameters); + set("channels", mapper.inquire()); } diff --git a/MQWeb/src/ChannelMapper.cpp b/MQWeb/src/ChannelMapper.cpp index 71d492c..845625e 100644 --- a/MQWeb/src/ChannelMapper.cpp +++ b/MQWeb/src/ChannelMapper.cpp @@ -19,13 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ChannelMapper.h" -#include "MQ/MQException.h" namespace MQ { namespace Web { -ChannelMapper::ChannelMapper(CommandServer& commandServer) : MQMapper(commandServer, "Channel") +ChannelMapper::ChannelMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Channel", input) { } @@ -34,48 +34,46 @@ ChannelMapper::~ChannelMapper() } -void ChannelMapper::change(const Poco::JSON::Object::Ptr&obj) +void ChannelMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void ChannelMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void ChannelMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void ChannelMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void ChannelMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr ChannelMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr ChannelMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_CHANNEL, filter); + createCommand(MQCMD_INQUIRE_CHANNEL); // Required Parameters - command.addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); + addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); // Optional Parameters - command.addAttributeList(MQIACF_CHANNEL_ATTRS, "ChannelAttrs"); - command.addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addParameterNumFromString(MQIACH_CHANNEL_DISP, "DefaultChannelDisposition"); - command.addIntegerFilter(); - command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); - command.addStringFilter(); + addAttributeList(MQIACF_CHANNEL_ATTRS, "ChannelAttrs"); + addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addParameterNumFromString(MQIACH_CHANNEL_DISP, "DefaultChannelDisposition"); + addIntegerFilter(); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addStringFilter(); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("ExcludeSystem", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); - Poco::JSON::Array::Ptr channels = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { @@ -92,13 +90,10 @@ Poco::JSON::Array::Ptr ChannelMapper::inquire(const Poco::JSON::Object::Ptr& fil continue; } - Poco::JSON::Object::Ptr channel = new Poco::JSON::Object(); - channels->add(channel); - - dictionary()->mapToJSON(**it, channel); + json->add(createJSON(**it)); } - return channels; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index 445f20f..1a7828b 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/ChannelStatusController.h" #include "MQ/Web/ChannelStatusMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -57,10 +56,8 @@ void ChannelStatusController::inquire() if ( form().has("instanceType") ) filter->set("instanceType", form().get("instanceType")); - ChannelStatusMapper channelStatusMapper(*commandServer()); - Poco::JSON::Array::Ptr statuses = channelStatusMapper.inquire(filter); - - set("statuses", statuses); + ChannelStatusMapper channelStatusMapper(*commandServer(), filter); + set("statuses", channelStatusMapper.inquire()); } diff --git a/MQWeb/src/ChannelStatusMapper.cpp b/MQWeb/src/ChannelStatusMapper.cpp index 7764821..73a448a 100644 --- a/MQWeb/src/ChannelStatusMapper.cpp +++ b/MQWeb/src/ChannelStatusMapper.cpp @@ -19,15 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ChannelStatusMapper.h" -#include "MQ/MQException.h" - -#include "Poco/JSON/Object.h" namespace MQ { namespace Web { -ChannelStatusMapper::ChannelStatusMapper(CommandServer& commandServer) : MQMapper(commandServer, "ChannelStatus") +ChannelStatusMapper::ChannelStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "ChannelStatus", input) { } @@ -36,35 +34,33 @@ ChannelStatusMapper::~ChannelStatusMapper() } -void ChannelStatusMapper::change(const Poco::JSON::Object::Ptr&obj) +void ChannelStatusMapper::change() { poco_assert_dbg(false); // Not applicable } -void ChannelStatusMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void ChannelStatusMapper::create(bool replace) { poco_assert_dbg(false); // Not applicable } -void ChannelStatusMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void ChannelStatusMapper::copy(bool replace) { poco_assert_dbg(false); // Not applicable } -Poco::JSON::Array::Ptr ChannelStatusMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr ChannelStatusMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_CHANNEL_STATUS, filter); + createCommand(MQCMD_INQUIRE_CHANNEL_STATUS); // Required parameters - command.addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); + addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); /*TODO: move to controller! - command.addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); + addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); if ( filter->has("type") ) { std::string channelType = filter->optValue("type", "All"); @@ -77,20 +73,20 @@ Poco::JSON::Array::Ptr ChannelStatusMapper::inquire(const Poco::JSON::Object::Pt }*/ // Optional parameters - command.addParameterNumFromString(MQIACH_CHANNEL_DISP, "ChannelDisposition"); - command.addParameter(MQCACH_CLIENT_ID, "ClientIdentifier"); - command.addAttributeList(MQIACH_CHANNEL_INSTANCE_ATTRS, "ChannelInstanceAttrs"); - command.addParameterNumFromString(MQIACH_CHANNEL_INSTANCE_TYPE, "ChannelInstanceType"); - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addParameter(MQCACH_CONNECTION_NAME, "ConnectionName"); - command.addIntegerFilter(); - command.addStringFilter(); - command.addParameter(MQCACH_XMIT_Q_NAME, "XmitQName"); + addParameterNumFromString(MQIACH_CHANNEL_DISP, "ChannelDisposition"); + addParameter(MQCACH_CLIENT_ID, "ClientIdentifier"); + addAttributeList(MQIACH_CHANNEL_INSTANCE_ATTRS, "ChannelInstanceAttrs"); + addParameterNumFromString(MQIACH_CHANNEL_INSTANCE_TYPE, "ChannelInstanceType"); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addParameter(MQCACH_CONNECTION_NAME, "ConnectionName"); + addIntegerFilter(); + addStringFilter(); + addParameter(MQCACH_XMIT_Q_NAME, "XmitQName"); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - Poco::JSON::Array::Ptr jsonStatuses = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { @@ -100,12 +96,10 @@ Poco::JSON::Array::Ptr ChannelStatusMapper::inquire(const Poco::JSON::Object::Pt if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) continue; - Poco::JSON::Object::Ptr jsonChannelStatus = new Poco::JSON::Object(); - dictionary()->mapToJSON(**it, jsonChannelStatus); - jsonStatuses->add(jsonChannelStatus); + json->add(createJSON(**it)); } - return jsonStatuses; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/ClusterQueueManagerController.cpp b/MQWeb/src/ClusterQueueManagerController.cpp index 7efa376..957b805 100644 --- a/MQWeb/src/ClusterQueueManagerController.cpp +++ b/MQWeb/src/ClusterQueueManagerController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/ClusterQueueManagerController.h" #include "MQ/Web/ClusterQueueManagerMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -59,9 +58,8 @@ void ClusterQueueManagerController::inquire() filter->set("channelName", channelNameField.empty() ? "*" : channelNameField); } - ClusterQueueManagerMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr clusqmgrs = mapper.inquire(filter); - set("clusqmgrs", clusqmgrs); + ClusterQueueManagerMapper mapper(*commandServer(), filter); + set("clusqmgrs", mapper.inquire()); } diff --git a/MQWeb/src/ClusterQueueManagerMapper.cpp b/MQWeb/src/ClusterQueueManagerMapper.cpp index b28404a..3a87f76 100644 --- a/MQWeb/src/ClusterQueueManagerMapper.cpp +++ b/MQWeb/src/ClusterQueueManagerMapper.cpp @@ -19,15 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ClusterQueueManagerMapper.h" -#include "MQ/MQException.h" - -#include "Poco/JSON/Object.h" namespace MQ { namespace Web { -ClusterQueueManagerMapper::ClusterQueueManagerMapper(CommandServer& commandServer) : MQMapper(commandServer, "ClusterQueueManager") +ClusterQueueManagerMapper::ClusterQueueManagerMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "ClusterQueueManager", input) { } @@ -36,45 +34,43 @@ ClusterQueueManagerMapper::~ClusterQueueManagerMapper() } -void ClusterQueueManagerMapper::change(const Poco::JSON::Object::Ptr&obj) +void ClusterQueueManagerMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void ClusterQueueManagerMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void ClusterQueueManagerMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void ClusterQueueManagerMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void ClusterQueueManagerMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr ClusterQueueManagerMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr ClusterQueueManagerMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_CLUSTER_Q_MGR, filter); + createCommand(MQCMD_INQUIRE_CLUSTER_Q_MGR); // Required parameters - command.addParameter(MQCA_CLUSTER_Q_MGR_NAME, "ClusterQmgrName"); + addParameter(MQCA_CLUSTER_Q_MGR_NAME, "ClusterQmgrName"); // Optional parameters - command.addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); - command.addParameter(MQCA_CLUSTER_NAME, "ClusterName"); - command.addAttributeList(MQIACF_CLUSTER_Q_MGR_ATTRS, "ClusterQMgrAttrs"); - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addIntegerFilter(); - command.addStringFilter(); + addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); + addParameter(MQCA_CLUSTER_NAME, "ClusterName"); + addAttributeList(MQIACF_CLUSTER_Q_MGR_ATTRS, "ClusterQMgrAttrs"); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addIntegerFilter(); + addStringFilter(); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - Poco::JSON::Array::Ptr clusqmgrs = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) @@ -83,13 +79,10 @@ Poco::JSON::Array::Ptr ClusterQueueManagerMapper::inquire(const Poco::JSON::Obje if ( (*it)->isExtendedResponse() ) // Skip extended response continue; - Poco::JSON::Object::Ptr clusqmgr = new Poco::JSON::Object(); - clusqmgrs->add(clusqmgr); - - dictionary()->mapToJSON(**it, clusqmgr); + json->add(createJSON(**it)); } - return clusqmgrs; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/ConnectionController.cpp b/MQWeb/src/ConnectionController.cpp index e18744d..8d55a10 100644 --- a/MQWeb/src/ConnectionController.cpp +++ b/MQWeb/src/ConnectionController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/ConnectionController.h" #include "MQ/Web/ConnectionMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -51,9 +50,8 @@ void ConnectionController::inquire() filter->set("id", parameters[1]); } - ConnectionMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(filter); - set("connections", json); + ConnectionMapper mapper(*commandServer(), filter); + set("connections", mapper.inquire()); } diff --git a/MQWeb/src/ConnectionMapper.cpp b/MQWeb/src/ConnectionMapper.cpp index d9ece8b..c9d54b6 100644 --- a/MQWeb/src/ConnectionMapper.cpp +++ b/MQWeb/src/ConnectionMapper.cpp @@ -19,16 +19,15 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ConnectionMapper.h" -#include "MQ/MQException.h" -#include "Poco/JSON/Object.h" #include "Poco/HexBinaryDecoder.h" namespace MQ { namespace Web { -ConnectionMapper::ConnectionMapper(CommandServer& commandServer) : MQMapper(commandServer, "Connection") +ConnectionMapper::ConnectionMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Connection", input) { } @@ -37,34 +36,32 @@ ConnectionMapper::~ConnectionMapper() } -void ConnectionMapper::change(const Poco::JSON::Object::Ptr&obj) +void ConnectionMapper::change() { poco_assert_dbg(false); // Not implemented } -void ConnectionMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void ConnectionMapper::create(bool replace) { poco_assert_dbg(false); // Not implemented } -void ConnectionMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void ConnectionMapper::copy(bool replace) { poco_assert_dbg(false); // Not implemented } -Poco::JSON::Array::Ptr ConnectionMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr ConnectionMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_CONNECTION, filter); + createCommand(MQCMD_INQUIRE_CONNECTION); // Required parameters - if ( filter->has("ConnectionId") ) + if ( _input->has("ConnectionId") ) { - std::string hexId = filter->get("ConnectionId"); + std::string hexId = _input->get("ConnectionId"); BufferPtr id = new Buffer(hexId.size() / 2); std::istringstream iss(hexId); @@ -77,27 +74,27 @@ Poco::JSON::Array::Ptr ConnectionMapper::inquire(const Poco::JSON::Object::Ptr& c = decoder.get(); } - command.pcf()->addParameter(MQBACF_CONNECTION_ID, id); + pcf()->addParameter(MQBACF_CONNECTION_ID, id); } else { BufferPtr id = new Buffer(0); // Empty buffer - command.pcf()->addParameter(MQBACF_GENERIC_CONNECTION_ID, id); + pcf()->addParameter(MQBACF_GENERIC_CONNECTION_ID, id); } // Optional parameters //TODO: ByteStringFilter - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addAttributeList(MQIACF_CONNECTION_ATTRS, "ConnectionAttrs"); - command.addParameterNumFromString(MQIACF_CONN_INFO_TYPE, "ConnInfoType"); - command.addIntegerFilter(); - command.addStringFilter(); - command.addParameterNumFromString(MQIA_UR_DISP, "URDisposition"); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addAttributeList(MQIACF_CONNECTION_ATTRS, "ConnectionAttrs"); + addParameterNumFromString(MQIACF_CONN_INFO_TYPE, "ConnInfoType"); + addIntegerFilter(); + addStringFilter(); + addParameterNumFromString(MQIA_UR_DISP, "URDisposition"); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - Poco::JSON::Array::Ptr connections = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) @@ -106,13 +103,10 @@ Poco::JSON::Array::Ptr ConnectionMapper::inquire(const Poco::JSON::Object::Ptr& if ( (*it)->isExtendedResponse() ) // Skip extended response continue; - Poco::JSON::Object::Ptr connection = new Poco::JSON::Object(); - connections->add(connection); - - dictionary()->mapToJSON(**it, connection); + json->add(createJSON(**it)); } - return connections; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/ListenerController.cpp b/MQWeb/src/ListenerController.cpp index af0404b..925223a 100644 --- a/MQWeb/src/ListenerController.cpp +++ b/MQWeb/src/ListenerController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/ListenerController.h" #include "MQ/Web/ListenerMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -64,9 +63,8 @@ void ListenerController::inquire() filter->set("excludeSystem", form().get("listenerExcludeSystem", "false").compare("true") == 0); } - ListenerMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr listeners = mapper.inquire(filter); - set("listeners", listeners); + ListenerMapper mapper(*commandServer(), filter); + set("listeners", mapper.inquire()); } diff --git a/MQWeb/src/ListenerMapper.cpp b/MQWeb/src/ListenerMapper.cpp index e2bd673..baf2027 100644 --- a/MQWeb/src/ListenerMapper.cpp +++ b/MQWeb/src/ListenerMapper.cpp @@ -19,13 +19,12 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ListenerMapper.h" -#include "MQ/Web/Dictionary.h" -#include "MQ/MQException.h" namespace MQ { namespace Web { -ListenerMapper::ListenerMapper(CommandServer& commandServer) : MQMapper(commandServer, "Listener") +ListenerMapper::ListenerMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Listener", input) { } @@ -34,45 +33,43 @@ ListenerMapper::~ListenerMapper() } -void ListenerMapper::change(const Poco::JSON::Object::Ptr&obj) +void ListenerMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void ListenerMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void ListenerMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void ListenerMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void ListenerMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr ListenerMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr ListenerMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_LISTENER, filter); + createCommand(MQCMD_INQUIRE_LISTENER); // Required parameters - command.addParameter(MQCACH_LISTENER_NAME, "ListenerName"); + addParameter(MQCACH_LISTENER_NAME, "ListenerName"); // Optional parameters - command.addIntegerFilter(); - command.addAttributeList(MQIACF_LISTENER_ATTRS, "ListenerAttrs"); - command.addStringFilter(); - command.addParameterNumFromString(MQIACH_XMIT_PROTOCOL_TYPE, "TransportType"); + addIntegerFilter(); + addAttributeList(MQIACF_LISTENER_ATTRS, "ListenerAttrs"); + addStringFilter(); + addParameterNumFromString(MQIACH_XMIT_PROTOCOL_TYPE, "TransportType"); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("ExcludeSystem", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); - Poco::JSON::Array::Ptr listeners = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->isExtendedResponse() ) // Skip extended response @@ -88,13 +85,10 @@ Poco::JSON::Array::Ptr ListenerMapper::inquire(const Poco::JSON::Object::Ptr& fi continue; } - Poco::JSON::Object::Ptr listener = new Poco::JSON::Object(); - listeners->add(listener); - - dictionary()->mapToJSON(**it, listener); + json->add(createJSON(**it)); } - return listeners; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/ListenerStatusController.cpp b/MQWeb/src/ListenerStatusController.cpp index c0b22f1..e84a5d2 100644 --- a/MQWeb/src/ListenerStatusController.cpp +++ b/MQWeb/src/ListenerStatusController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/ListenerStatusController.h" #include "MQ/Web/ListenerStatusMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -61,9 +60,8 @@ void ListenerStatusController::inquire() filter->set("name", listenerNameField); } - ListenerStatusMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr statuses = mapper.inquire(filter); - set("statuses", statuses); + ListenerStatusMapper mapper(*commandServer(), filter); + set("statuses", mapper.inquire()); } diff --git a/MQWeb/src/ListenerStatusMapper.cpp b/MQWeb/src/ListenerStatusMapper.cpp index 2630117..2381fee 100644 --- a/MQWeb/src/ListenerStatusMapper.cpp +++ b/MQWeb/src/ListenerStatusMapper.cpp @@ -19,13 +19,12 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ListenerStatusMapper.h" -#include "MQ/Web/Dictionary.h" -#include "MQ/MQException.h" namespace MQ { namespace Web { -ListenerStatusMapper::ListenerStatusMapper(CommandServer& commandServer) : MQMapper(commandServer, "ListenerStatus") +ListenerStatusMapper::ListenerStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "ListenerStatus", input) { } @@ -34,40 +33,38 @@ ListenerStatusMapper::~ListenerStatusMapper() } -void ListenerStatusMapper::change(const Poco::JSON::Object::Ptr&obj) +void ListenerStatusMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void ListenerStatusMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void ListenerStatusMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void ListenerStatusMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void ListenerStatusMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr ListenerStatusMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr ListenerStatusMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_LISTENER_STATUS, filter); + createCommand(MQCMD_INQUIRE_LISTENER_STATUS); // Required parameters - command.addParameter(MQCACH_LISTENER_NAME, "ListenerName"); + addParameter(MQCACH_LISTENER_NAME, "ListenerName"); // Optional parameters - command.addIntegerFilter(); - command.addAttributeList(MQIACF_LISTENER_STATUS_ATTRS, "ListenerStatusAttrs"); - command.addStringFilter(); + addIntegerFilter(); + addAttributeList(MQIACF_LISTENER_STATUS_ATTRS, "ListenerStatusAttrs"); + addStringFilter(); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); Poco::JSON::Array::Ptr statuses = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) @@ -78,10 +75,7 @@ Poco::JSON::Array::Ptr ListenerStatusMapper::inquire(const Poco::JSON::Object::P if ( (*it)->getReasonCode() != MQRC_NONE ) continue; - Poco::JSON::Object::Ptr status = new Poco::JSON::Object(); - statuses->add(status); - - dictionary()->mapToJSON(**it, status); + statuses->add(createJSON(**it)); } return statuses; diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index 607b0ef..f9a0a31 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -31,7 +31,9 @@ namespace Web { DictionaryCache MQMapper::_dictionaryCache; -MQMapper::MQMapper(CommandServer& commandServer, const std::string& objectType) : _commandServer(commandServer) +MQMapper::MQMapper(CommandServer& commandServer, const std::string& objectType, Poco::JSON::Object::Ptr input) + : _commandServer(commandServer) + , _input(input) { _dictionary = _dictionaryCache.getDictionary(objectType); poco_assert_dbg(!_dictionary.isNull()); @@ -90,25 +92,16 @@ const DisplayMap& MQMapper::getDisplayMap(const std::string& objectType, MQLONG return dict->getDisplayMap(id); } -MQMapper::Command::Command(MQMapper* mapper, MQLONG command, Poco::JSON::Object::Ptr filter) -: _mapper(mapper) -, _filter(filter) +void MQMapper::addIntegerFilter() { - _pcf = _mapper->_commandServer.createCommand(command); -} - -MQMapper::Command::~Command() -{ -} + poco_assert_dbg(!_pcf.isNull()); -void MQMapper::Command::addIntegerFilter() -{ - Poco::JSON::Object::Ptr integerFilter = _filter->getObject("IntegerFilterCommand"); + Poco::JSON::Object::Ptr integerFilter = _input->getObject("IntegerFilterCommand"); if ( integerFilter.isNull() ) return; std::string parameterName = integerFilter->optValue("Parameter", ""); - MQLONG parameter = _mapper->dictionary()->getId(parameterName); + MQLONG parameter = _dictionary->getId(parameterName); if ( parameter == -1 ) return; @@ -121,7 +114,7 @@ void MQMapper::Command::addIntegerFilter() if ( value.isString() ) { // A String is passed ... try to find the MQ integer value - filterValue = _mapper->dictionary()->getDisplayId(parameter, value); + filterValue = _dictionary->getDisplayId(parameter, value); } else if ( value.isNumeric() ) { @@ -130,14 +123,16 @@ void MQMapper::Command::addIntegerFilter() _pcf->addFilter(parameter, op, filterValue); } -void MQMapper::Command::addStringFilter() +void MQMapper::addStringFilter() { - Poco::JSON::Object::Ptr stringFilter = _filter->getObject("StringFilterCommand"); + poco_assert_dbg(!_pcf.isNull()); + + Poco::JSON::Object::Ptr stringFilter = _input->getObject("StringFilterCommand"); if ( stringFilter.isNull() ) return; std::string parameterName = stringFilter->optValue("Parameter", ""); - MQLONG parameter = _mapper->dictionary()->getId(parameterName); + MQLONG parameter = _dictionary->getId(parameterName); if ( parameter == -1 ) return; @@ -149,17 +144,19 @@ void MQMapper::Command::addStringFilter() _pcf->addFilter(parameter, op, filterValue); } -void MQMapper::Command::addAttributeList(MQLONG attrId, const std::string& attr) +void MQMapper::addAttributeList(MQLONG attrId, const std::string& attr) { - if ( _filter->has(attr) ) + poco_assert_dbg(!_pcf.isNull()); + + if ( _input->has(attr) ) { - Poco::JSON::Array::Ptr attrs = _filter->getArray(attr); + Poco::JSON::Array::Ptr attrs = _input->getArray(attr); if ( !attrs.isNull() && attrs->size() > 0 ) { std::vector numList; for(Poco::JSON::Array::ValueVec::const_iterator it = attrs->begin(); it != attrs->end(); ++it) { - MQLONG id = _mapper->dictionary()->getId(*it); + MQLONG id = _dictionary->getId(*it); if ( id != -1 ) numList.push_back(id); } if ( numList.size() > 0 ) _pcf->addParameterList(attrId, numList); @@ -167,15 +164,17 @@ void MQMapper::Command::addAttributeList(MQLONG attrId, const std::string& attr) } } -void MQMapper::Command::addParameterNumFromString(MQLONG parameter, const std::string& name) +void MQMapper::addParameterNumFromString(MQLONG parameter, const std::string& name) { - Poco::Dynamic::Var value = _filter->get(name); + poco_assert_dbg(!_pcf.isNull()); + + Poco::Dynamic::Var value = _input->get(name); if ( ! value.isEmpty() ) { try { std::string stringValue = value.convert(); - MQLONG numValue = _mapper->dictionary()->getDisplayId(parameter, stringValue); + MQLONG numValue = _dictionary->getDisplayId(parameter, stringValue); poco_assert_dbg(numValue != -1); if ( numValue != - 1 ) { @@ -189,18 +188,18 @@ void MQMapper::Command::addParameterNumFromString(MQLONG parameter, const std::s } } -void MQMapper::Command::execute(PCF::Vector& response) +void MQMapper::execute(PCF::Vector& response) { - poco_check_ptr(_pcf); - _mapper->_commandServer.sendCommand(_pcf, response); + poco_assert_dbg(!_pcf.isNull()); + _commandServer.sendCommand(_pcf, response); if ( response.size() > 0 ) { PCF::Vector::const_iterator it = response.begin(); - if ( (*it)->getCompletionCode() == MQCC_FAILED - && (*it)->getReasonCode() > 3000 - && (*it)->getReasonCode() < 4000 - && (*it)->getReasonCode() != MQRCCF_NONE_FOUND ) + if ( (*it)->getCompletionCode() == MQCC_FAILED + && (*it)->getReasonCode() > 3000 + && (*it)->getReasonCode() < 4000 + && (*it)->getReasonCode() != MQRCCF_NONE_FOUND ) { static Poco::SharedPtr dict = _dictionaryCache.getDictionary("Event"); std::string command = dict->getDisplayValue(MQIACF_COMMAND, (*it)->getCommand()); diff --git a/MQWeb/src/NamelistController.cpp b/MQWeb/src/NamelistController.cpp index 4042f4e..ca6034c 100644 --- a/MQWeb/src/NamelistController.cpp +++ b/MQWeb/src/NamelistController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/NamelistController.h" #include "MQ/Web/NamelistMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -57,9 +56,8 @@ void NamelistController::inquire() filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); } - NamelistMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(filter); - set("namelists", json); + NamelistMapper mapper(*commandServer(), filter); + set("namelists", mapper.inquire()); } diff --git a/MQWeb/src/NamelistMapper.cpp b/MQWeb/src/NamelistMapper.cpp index 904c9a2..215f9b8 100644 --- a/MQWeb/src/NamelistMapper.cpp +++ b/MQWeb/src/NamelistMapper.cpp @@ -19,15 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/NamelistMapper.h" -#include "MQ/MQException.h" - -#include "Poco/JSON/Object.h" namespace MQ { namespace Web { -NamelistMapper::NamelistMapper(CommandServer& commandServer) : MQMapper(commandServer, "Namelist") +NamelistMapper::NamelistMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Namelist", input) { } @@ -36,46 +34,44 @@ NamelistMapper::~NamelistMapper() } -void NamelistMapper::change(const Poco::JSON::Object::Ptr&obj) +void NamelistMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void NamelistMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void NamelistMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void NamelistMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void NamelistMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr NamelistMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr NamelistMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_NAMELIST, filter); + createCommand(MQCMD_INQUIRE_NAMELIST); // Required parameters - command.addParameter(MQCA_NAMELIST_NAME, "NamelistName"); + addParameter(MQCA_NAMELIST_NAME, "NamelistName"); // Optional parameters - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addIntegerFilter(); - command.addAttributeList(MQIACF_NAMELIST_ATTRS, "NamelistAttrs"); - command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); - command.addStringFilter(); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addIntegerFilter(); + addAttributeList(MQIACF_NAMELIST_ATTRS, "NamelistAttrs"); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addStringFilter(); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("ExcludeSystem", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); - Poco::JSON::Array::Ptr namelists = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) @@ -91,13 +87,10 @@ Poco::JSON::Array::Ptr NamelistMapper::inquire(const Poco::JSON::Object::Ptr& fi continue; } - Poco::JSON::Object::Ptr namelist = new Poco::JSON::Object(); - namelists->add(namelist); - - dictionary()->mapToJSON(**it, namelist); + json->add(createJSON(**it)); } - return namelists; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/ProcessController.cpp b/MQWeb/src/ProcessController.cpp index 4baac68..3da2810 100644 --- a/MQWeb/src/ProcessController.cpp +++ b/MQWeb/src/ProcessController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/ProcessController.h" #include "MQ/Web/ProcessMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -57,9 +56,8 @@ void ProcessController::inquire() filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); } - ProcessMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(filter); - set("processes", json); + ProcessMapper mapper(*commandServer(), filter); + set("processes", mapper.inquire()); } diff --git a/MQWeb/src/ProcessMapper.cpp b/MQWeb/src/ProcessMapper.cpp index b570ced..e0d27ed 100644 --- a/MQWeb/src/ProcessMapper.cpp +++ b/MQWeb/src/ProcessMapper.cpp @@ -19,15 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ProcessMapper.h" -#include "MQ/MQException.h" - -#include "Poco/JSON/Object.h" namespace MQ { namespace Web { -ProcessMapper::ProcessMapper(CommandServer& commandServer) : MQMapper(commandServer, "Process") +ProcessMapper::ProcessMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Process", input) { } @@ -36,46 +34,44 @@ ProcessMapper::~ProcessMapper() } -void ProcessMapper::change(const Poco::JSON::Object::Ptr&obj) +void ProcessMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void ProcessMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void ProcessMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void ProcessMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void ProcessMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr ProcessMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr ProcessMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_PROCESS, filter); + createCommand(MQCMD_INQUIRE_PROCESS); // Required parameters - command.addParameter(MQCA_PROCESS_NAME, "ProcessName"); + addParameter(MQCA_PROCESS_NAME, "ProcessName"); // Optional parameters - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addIntegerFilter(); - command.addAttributeList(MQIACF_PROCESS_ATTRS, "ProcessAttrs"); - command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); - command.addStringFilter(); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addIntegerFilter(); + addAttributeList(MQIACF_PROCESS_ATTRS, "ProcessAttrs"); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addStringFilter(); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("ExcludeSystem", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); - Poco::JSON::Array::Ptr processes = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) @@ -91,13 +87,10 @@ Poco::JSON::Array::Ptr ProcessMapper::inquire(const Poco::JSON::Object::Ptr& fil continue; } - Poco::JSON::Object::Ptr process = new Poco::JSON::Object(); - processes->add(process); - - dictionary()->mapToJSON(**it, process); + json->add(createJSON(**it)); } - return processes; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index 7e9fa7b..9db8fc3 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/QueueController.h" #include "MQ/Web/QueueMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -185,10 +184,8 @@ void QueueController::inquire() } } - QueueMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr queues = mapper.inquire(pcfParameters); - set("queues", queues); - setView(new JSONView()); + QueueMapper mapper(*commandServer(), pcfParameters); + set("queues", mapper.inquire()); } diff --git a/MQWeb/src/QueueManagerController.cpp b/MQWeb/src/QueueManagerController.cpp index d101149..c88ab7f 100644 --- a/MQWeb/src/QueueManagerController.cpp +++ b/MQWeb/src/QueueManagerController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/QueueManagerController.h" #include "MQ/Web/QueueManagerMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -40,14 +39,12 @@ QueueManagerController::~QueueManagerController() void QueueManagerController::inquire() { - QueueManagerMapper queueManagerMapper(*commandServer()); + QueueManagerMapper mapper(*commandServer(), new Poco::JSON::Object()); - Poco::JSON::Object::Ptr dummyFilter = new Poco::JSON::Object(); - Poco::JSON::Array::Ptr jsonQueueManagers = queueManagerMapper.inquire(dummyFilter); - - if ( jsonQueueManagers->size() > 0 ) + Poco::JSON::Array::Ptr json = mapper.inquire(); + if ( json->size() > 0 ) { - set("qmgr", jsonQueueManagers->get(0)); + set("qmgr", json->get(0)); } } diff --git a/MQWeb/src/QueueManagerMapper.cpp b/MQWeb/src/QueueManagerMapper.cpp index 0e6f46e..843b652 100644 --- a/MQWeb/src/QueueManagerMapper.cpp +++ b/MQWeb/src/QueueManagerMapper.cpp @@ -19,15 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/QueueManagerMapper.h" -#include "MQ/MQException.h" - -#include "Poco/JSON/Object.h" namespace MQ { namespace Web { -QueueManagerMapper::QueueManagerMapper(CommandServer& commandServer) : MQMapper(commandServer, "QueueManager") +QueueManagerMapper::QueueManagerMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "QueueManager", input) { } @@ -36,49 +34,46 @@ QueueManagerMapper::~QueueManagerMapper() } -void QueueManagerMapper::change(const Poco::JSON::Object::Ptr&obj) +void QueueManagerMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void QueueManagerMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void QueueManagerMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void QueueManagerMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void QueueManagerMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr QueueManagerMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr QueueManagerMapper::inquire() { - Poco::JSON::Array::Ptr jsonQueueManagers = new Poco::JSON::Array(); - - Command command(this, MQCMD_INQUIRE_Q_MGR, filter); + createCommand(MQCMD_INQUIRE_Q_MGR); // Optional parameters - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addAttributeList(MQIACF_Q_MGR_ATTRS, "QMgrAttrs"); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addAttributeList(MQIACF_Q_MGR_ATTRS, "QMgrAttrs"); std::vector > commandResponse; - command.execute(commandResponse); + execute(commandResponse); + + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->isExtendedResponse() ) // Skip extended response continue; - Poco::JSON::Object::Ptr jsonQmgr = new Poco::JSON::Object(); - jsonQueueManagers->add(jsonQmgr); - - dictionary()->mapToJSON(**it, jsonQmgr); + json->add(createJSON(**it)); } - return jsonQueueManagers; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/QueueManagerStatusController.cpp b/MQWeb/src/QueueManagerStatusController.cpp index b7daff6..eda5634 100644 --- a/MQWeb/src/QueueManagerStatusController.cpp +++ b/MQWeb/src/QueueManagerStatusController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/QueueManagerStatusController.h" #include "MQ/Web/QueueManagerStatusMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -47,14 +46,12 @@ void QueueManagerStatusController::inquire() return; } - QueueManagerStatusMapper queueManagerStatusMapper(*commandServer()); + QueueManagerStatusMapper mapper(*commandServer(), new Poco::JSON::Object()); + Poco::JSON::Array::Ptr json = mapper.inquire(); - Poco::JSON::Object::Ptr dummyFilter = new Poco::JSON::Object(); - Poco::JSON::Array::Ptr jsonQueueManagers = queueManagerStatusMapper.inquire(dummyFilter); - - if ( jsonQueueManagers->size() > 0 ) + if ( json->size() > 0 ) { - set("status", jsonQueueManagers->get(0)); + set("status", json->get(0)); } } diff --git a/MQWeb/src/QueueManagerStatusMapper.cpp b/MQWeb/src/QueueManagerStatusMapper.cpp index e6d2f09..97a4859 100644 --- a/MQWeb/src/QueueManagerStatusMapper.cpp +++ b/MQWeb/src/QueueManagerStatusMapper.cpp @@ -19,15 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/QueueManagerStatusMapper.h" -#include "MQ/MQException.h" - -#include "Poco/JSON/Object.h" namespace MQ { namespace Web { -QueueManagerStatusMapper::QueueManagerStatusMapper(CommandServer& commandServer) : MQMapper(commandServer, "QueueManagerStatus") +QueueManagerStatusMapper::QueueManagerStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "QueueManagerStatus", input) { } @@ -36,35 +34,35 @@ QueueManagerStatusMapper::~QueueManagerStatusMapper() } -void QueueManagerStatusMapper::change(const Poco::JSON::Object::Ptr&obj) +void QueueManagerStatusMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void QueueManagerStatusMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void QueueManagerStatusMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void QueueManagerStatusMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void QueueManagerStatusMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr QueueManagerStatusMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr QueueManagerStatusMapper::inquire() { - Command command(this, MQCMD_INQUIRE_Q_MGR_STATUS, filter); + createCommand(MQCMD_INQUIRE_Q_MGR_STATUS); // Optional parameters - command.addAttributeList(MQIACF_Q_MGR_STATUS_ATTRS, "QMStatusAttrs"); + addAttributeList(MQIACF_Q_MGR_STATUS_ATTRS, "QMStatusAttrs"); std::vector > commandResponse; - command.execute(commandResponse); + execute(commandResponse); - Poco::JSON::Array::Ptr jsonQueueManagerStatuses = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->isExtendedResponse() ) // Skip extended response @@ -73,13 +71,10 @@ Poco::JSON::Array::Ptr QueueManagerStatusMapper::inquire(const Poco::JSON::Objec if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) continue; - Poco::JSON::Object::Ptr jsonQmgr = new Poco::JSON::Object(); - jsonQueueManagerStatuses->add(jsonQmgr); - - dictionary()->mapToJSON(**it, jsonQmgr); + json->add(createJSON(**it)); } - return jsonQueueManagerStatuses; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/QueueMapper.cpp b/MQWeb/src/QueueMapper.cpp index 2ba9f1c..2e2998f 100644 --- a/MQWeb/src/QueueMapper.cpp +++ b/MQWeb/src/QueueMapper.cpp @@ -19,13 +19,12 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/QueueMapper.h" -#include "MQ/Web/Dictionary.h" -#include "MQ/MQException.h" namespace MQ { namespace Web { -QueueMapper::QueueMapper(CommandServer& commandServer) : MQMapper(commandServer, "Queue") +QueueMapper::QueueMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Queue", input) { } @@ -34,63 +33,61 @@ QueueMapper::~QueueMapper() } -void QueueMapper::change(const Poco::JSON::Object::Ptr&obj) +void QueueMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void QueueMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void QueueMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void QueueMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void QueueMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr QueueMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_Q, filter); + createCommand(MQCMD_INQUIRE_Q); // Required Parameters - command.addParameter(MQCA_Q_NAME, "QName"); + addParameter(MQCA_Q_NAME, "QName"); // Optional Parameters - command.addParameter(MQCA_CF_STRUC_NAME, "CFStructure"); + addParameter(MQCA_CF_STRUC_NAME, "CFStructure"); - Poco::Dynamic::Var clusterInfo = filter->get("ClusterInfo"); + Poco::Dynamic::Var clusterInfo = _input->get("ClusterInfo"); if (! clusterInfo.isEmpty() ) { try { - command.pcf()->addParameter(MQIACF_CLUSTER_INFO, clusterInfo.convert() == true); + pcf()->addParameter(MQIACF_CLUSTER_INFO, clusterInfo.convert() == true); } catch(...) { poco_assert_dbg(false); } } - command.addParameter(MQCA_CLUSTER_NAME, "ClusterName"); - command.addParameter(MQCA_CLUSTER_NAMELIST, "ClusterNamelist"); - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addIntegerFilter(); - command.addParameter(MQIA_PAGESET_ID, "PageSetId"); - command.addStringFilter(); - command.addParameterNumFromString(MQIA_Q_TYPE, "QType"); - command.addAttributeList(MQIACF_Q_ATTRS, "QAttrs"); - command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addParameter(MQCA_CLUSTER_NAME, "ClusterName"); + addParameter(MQCA_CLUSTER_NAMELIST, "ClusterNamelist"); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addIntegerFilter(); + addParameter(MQIA_PAGESET_ID, "PageSetId"); + addStringFilter(); + addParameterNumFromString(MQIA_Q_TYPE, "QType"); + addAttributeList(MQIACF_Q_ATTRS, "QAttrs"); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); MQLONG usage = -1; - if ( filter->has("Usage") ) + if ( _input->has("Usage") ) { - std::string usageValue = filter->optValue("Usage", ""); - if ( Poco::icompare(usageValue, "Transmission") == 0 + std::string usageValue = _input->optValue("Usage", ""); + if ( Poco::icompare(usageValue, "Transmission") == 0 || Poco::icompare(usageValue, "XmitQ") == 0 ) { usage = MQUS_TRANSMISSION; @@ -102,12 +99,12 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte } PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("ExcludeSystem", false); - bool excludeTemp = filter->optValue("ExcludeTemp", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); + bool excludeTemp = _input->optValue("ExcludeTemp", false); - Poco::JSON::Array::Ptr jsonQueues = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->isExtendedResponse() ) // Skip extended response @@ -139,13 +136,10 @@ Poco::JSON::Array::Ptr QueueMapper::inquire(const Poco::JSON::Object::Ptr& filte continue; } - Poco::JSON::Object::Ptr jsonQueue = new Poco::JSON::Object(); - jsonQueues->add(jsonQueue); - - dictionary()->mapToJSON(**it, jsonQueue); + json->add(createJSON(**it)); } - return jsonQueues; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/QueueStatusController.cpp b/MQWeb/src/QueueStatusController.cpp index 7961ea2..d1727ad 100644 --- a/MQWeb/src/QueueStatusController.cpp +++ b/MQWeb/src/QueueStatusController.cpp @@ -20,7 +20,6 @@ */ #include "MQ/Web/QueueStatusController.h" #include "MQ/Web/QueueStatusMapper.h" -#include "MQ/Web/JSONView.h" namespace MQ { @@ -65,9 +64,8 @@ void QueueStatusController::inquire() if ( form().has("statusType") ) filter->set("statusType", form().get("statusType")); if ( form().has("openType") ) filter->set("openType", form().get("openType")); - QueueStatusMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(filter); - set("statuses", json); + QueueStatusMapper mapper(*commandServer(), filter); + set("statuses", mapper.inquire()); } diff --git a/MQWeb/src/QueueStatusMapper.cpp b/MQWeb/src/QueueStatusMapper.cpp index 19274d4..2df0b33 100644 --- a/MQWeb/src/QueueStatusMapper.cpp +++ b/MQWeb/src/QueueStatusMapper.cpp @@ -19,13 +19,12 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/QueueStatusMapper.h" -#include "MQ/Web/Dictionary.h" -#include "MQ/MQException.h" namespace MQ { namespace Web { -QueueStatusMapper::QueueStatusMapper(CommandServer& commandServer) : MQMapper(commandServer, "QueueStatus") +QueueStatusMapper::QueueStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "QueueStatus", input) { } @@ -34,50 +33,48 @@ QueueStatusMapper::~QueueStatusMapper() } -void QueueStatusMapper::change(const Poco::JSON::Object::Ptr&obj) +void QueueStatusMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void QueueStatusMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void QueueStatusMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void QueueStatusMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void QueueStatusMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr QueueStatusMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr QueueStatusMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); - - Command command(this, MQCMD_INQUIRE_Q_STATUS, filter); + createCommand(MQCMD_INQUIRE_Q_STATUS); // Required parameters - command.addParameter(MQCA_Q_NAME, "QName"); + addParameter(MQCA_Q_NAME, "QName"); // Optional parameters //TODO: ByteStringFilter - command.addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); - command.addIntegerFilter(); - command.addParameterNumFromString(MQIACF_OPEN_TYPE, "OpenType"); - command.addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); - command.addAttributeList(MQIACF_Q_STATUS_ATTRS, "QStatusAttrs"); - command.addParameterNumFromString(MQIACF_STATUS_TYPE, "StatusType"); - command.addStringFilter(); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addIntegerFilter(); + addParameterNumFromString(MQIACF_OPEN_TYPE, "OpenType"); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addAttributeList(MQIACF_Q_STATUS_ATTRS, "QStatusAttrs"); + addParameterNumFromString(MQIACF_STATUS_TYPE, "StatusType"); + addStringFilter(); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("ExcludeSystem", false); - bool excludeTemp = filter->optValue("ExcludeTemp", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); + bool excludeTemp = _input->optValue("ExcludeTemp", false); + + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { @@ -101,10 +98,7 @@ Poco::JSON::Array::Ptr QueueStatusMapper::inquire(const Poco::JSON::Object::Ptr& continue; } - Poco::JSON::Object::Ptr jsonStatus = new Poco::JSON::Object(); - json->add(jsonStatus); - - dictionary()->mapToJSON(**it, jsonStatus); + json->add(createJSON(**it)); } return json; diff --git a/MQWeb/src/ServiceController.cpp b/MQWeb/src/ServiceController.cpp index 9fe501d..f379e76 100644 --- a/MQWeb/src/ServiceController.cpp +++ b/MQWeb/src/ServiceController.cpp @@ -57,9 +57,8 @@ void ServiceController::inquire() filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); } - ServiceMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr json = mapper.inquire(filter); - set("services", json); + ServiceMapper mapper(*commandServer(), filter); + set("services", mapper.inquire()); } diff --git a/MQWeb/src/ServiceMapper.cpp b/MQWeb/src/ServiceMapper.cpp index 0eb4c14..ba090f8 100644 --- a/MQWeb/src/ServiceMapper.cpp +++ b/MQWeb/src/ServiceMapper.cpp @@ -19,15 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ServiceMapper.h" -#include "MQ/MQException.h" - -#include "Poco/JSON/Object.h" namespace MQ { namespace Web { -ServiceMapper::ServiceMapper(CommandServer& commandServer) : MQMapper(commandServer, "Service") +ServiceMapper::ServiceMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Service", input) { } @@ -36,44 +34,42 @@ ServiceMapper::~ServiceMapper() } -void ServiceMapper::change(const Poco::JSON::Object::Ptr&obj) +void ServiceMapper::change() { poco_assert_dbg(false); // Not yet implemented } -void ServiceMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace) +void ServiceMapper::create(bool replace) { poco_assert_dbg(false); // Not yet implemented } -void ServiceMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace) +void ServiceMapper::copy(bool replace) { poco_assert_dbg(false); // Not yet implemented } -Poco::JSON::Array::Ptr ServiceMapper::inquire(const Poco::JSON::Object::Ptr& filter) +Poco::JSON::Array::Ptr ServiceMapper::inquire() { - poco_assert_dbg(!filter.isNull()); - - Command command(this, MQCMD_INQUIRE_SERVICE, filter); + createCommand(MQCMD_INQUIRE_SERVICE); // Required parameters - command.addParameter(MQCA_SERVICE_NAME, "ServiceName"); + addParameter(MQCA_SERVICE_NAME, "ServiceName"); // Optional parameters - command.addIntegerFilter(); - command.addAttributeList(MQIACF_SERVICE_ATTRS, "ServiceAttrs"); - command.addStringFilter(); + addIntegerFilter(); + addAttributeList(MQIACF_SERVICE_ATTRS, "ServiceAttrs"); + addStringFilter(); PCF::Vector commandResponse; - command.execute(commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("ExcludeSystem", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); - Poco::JSON::Array::Ptr services = new Poco::JSON::Array(); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) @@ -88,13 +84,10 @@ Poco::JSON::Array::Ptr ServiceMapper::inquire(const Poco::JSON::Object::Ptr& fil continue; } - Poco::JSON::Object::Ptr service = new Poco::JSON::Object(); - services->add(service); - - dictionary()->mapToJSON(**it, service); + json->add(createJSON(**it)); } - return services; + return json; } }} // Namespace MQ::Web From a636ade7a983f9b0986c98c63087a97bcc6e5b38 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Fri, 12 Sep 2014 13:59:59 +0200 Subject: [PATCH 052/143] Wrong initialisation in ctor --- MQWeb/src/AuthorityRecordMapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQWeb/src/AuthorityRecordMapper.cpp b/MQWeb/src/AuthorityRecordMapper.cpp index 908099d..1795203 100644 --- a/MQWeb/src/AuthorityRecordMapper.cpp +++ b/MQWeb/src/AuthorityRecordMapper.cpp @@ -24,7 +24,7 @@ namespace MQ { namespace Web { AuthorityRecordMapper::AuthorityRecordMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) -: MQMapper(commandServer, "AuthorityRecord", _input) +: MQMapper(commandServer, "AuthorityRecord", input) { } From f0c1755d990f93dd50a74332774fb77697b5c209 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Mon, 15 Sep 2014 15:06:58 +0200 Subject: [PATCH 053/143] Add authrec inquire sample --- samples/authrec_inq.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 samples/authrec_inq.pl diff --git a/samples/authrec_inq.pl b/samples/authrec_inq.pl new file mode 100644 index 0000000..142aec7 --- /dev/null +++ b/samples/authrec_inq.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl +use strict; +use warnings; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = '{ "ProfileName" : "", "Options" : ["Name All Matching", "Entity Explicit"] }'; + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/authrec/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json); + +my $res = $ua->request($req); + +print $res->content(); From 3f96bf55baaf810791a8c091061fdb63ff1b07cb Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 16 Sep 2014 22:40:55 +0200 Subject: [PATCH 054/143] Shell script for generating highlighted code for the MQWeb GitHub pages --- samples/pygmentize_samples.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 samples/pygmentize_samples.sh diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh new file mode 100755 index 0000000..50f2a36 --- /dev/null +++ b/samples/pygmentize_samples.sh @@ -0,0 +1,7 @@ +#!/bin/bash +if [ -z "$1" ] + then + echo "I need one argument: the root folder of the MQWeb GitHub pages" + exit +fi +pygmentize -o $1/api/samples/queue.html ./queue.pl From 862b811dee726e90c36f54fa79f2d9a9128436de Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Wed, 17 Sep 2014 11:14:39 +0200 Subject: [PATCH 055/143] Update URI --- samples/guzzle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/guzzle.php b/samples/guzzle.php index 7a67a57..d844cd8 100644 --- a/samples/guzzle.php +++ b/samples/guzzle.php @@ -8,6 +8,6 @@ // Create a client and provide a base URL $client = new Client('http://localhost:8081'); -$data = $client->get('queue/inquire/PIGEON')->send()->json(); +$data = $client->get('api/queue/inquire/PIGEON')->send()->json(); print_r($data); From 2434150dd1bb4079a84c24a27f72daf43f11f1ad Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 17 Sep 2014 19:12:44 +0200 Subject: [PATCH 056/143] Change order of optional parameters --- MQWeb/src/ChannelMapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQWeb/src/ChannelMapper.cpp b/MQWeb/src/ChannelMapper.cpp index 845625e..477d236 100644 --- a/MQWeb/src/ChannelMapper.cpp +++ b/MQWeb/src/ChannelMapper.cpp @@ -60,8 +60,8 @@ Poco::JSON::Array::Ptr ChannelMapper::inquire() addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); // Optional Parameters - addAttributeList(MQIACF_CHANNEL_ATTRS, "ChannelAttrs"); addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); + addAttributeList(MQIACF_CHANNEL_ATTRS, "ChannelAttrs"); addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); addParameterNumFromString(MQIACH_CHANNEL_DISP, "DefaultChannelDisposition"); addIntegerFilter(); From 7f3dba7fcb805fff0f3040ef9bf1c242c37c6e87 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 17 Sep 2014 19:13:52 +0200 Subject: [PATCH 057/143] Add CommandScope, DefaultChannelDisposition, ... --- MQWeb/src/ChannelController.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/MQWeb/src/ChannelController.cpp b/MQWeb/src/ChannelController.cpp index 89cce87..2f5dbe6 100644 --- a/MQWeb/src/ChannelController.cpp +++ b/MQWeb/src/ChannelController.cpp @@ -70,7 +70,7 @@ void ChannelController::inquire() { pcfParameters->set("ChannelType", parameters[2]); } - else + else if ( form().has("ChannelType") ) { pcfParameters->set("ChannelType", form().get("ChannelType", "All")); } @@ -78,20 +78,32 @@ void ChannelController::inquire() pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); - pcfParameters->set("ChannelAttrs", attrs); + formElementToJSONArray("ChannelAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ChannelAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ChannelAttrs", attrs); + } - Poco::Net::NameValueCollection::ConstIterator itAttrs = form().find("ChannelAttrs"); - if ( itAttrs == form().end() ) + if ( form().has("CommandScope") ) { - itAttrs = form().find("Attrs"); + pcfParameters->set("CommandScope", form().get("CommandScope")); } - for(; - itAttrs != form().end() && Poco::icompare(itAttrs->first, "Attrs") == 0; - ++itAttrs) + if ( form().has("QSGDisposition") ) { - attrs->add(itAttrs->second); + pcfParameters->set("QSGDisposition", form().get("QSGDisposition")); } + + if ( form().has("DefaultChannelDisposition") ) + { + pcfParameters->set("DefaultChannelDisposition", form().get("DefaultChannelDisposition")); + } + + handleFilterForm(pcfParameters); } ChannelMapper mapper(*commandServer(), pcfParameters); From dc9f814e2f254d9da16e9209ab820be4cf95e166 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 17 Sep 2014 19:14:15 +0200 Subject: [PATCH 058/143] When no ProfileName is set, set it to blancs --- MQWeb/src/AuthorityRecordMapper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MQWeb/src/AuthorityRecordMapper.cpp b/MQWeb/src/AuthorityRecordMapper.cpp index 1795203..82cf129 100644 --- a/MQWeb/src/AuthorityRecordMapper.cpp +++ b/MQWeb/src/AuthorityRecordMapper.cpp @@ -87,6 +87,8 @@ Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire() } pcf()->addParameter(MQIACF_AUTH_OPTIONS, options); } + // When no ProfileName is passed, set to empty string + if ( !_input->has("ProfileName") ) _input->set("ProfileName", ""); addParameter(MQCACF_AUTH_PROFILE_NAME, "ProfileName"); addParameterNumFromString(MQIACF_OBJECT_TYPE, "ObjectType"); From 1f2ccb31243497a34864ddaf8086999f99fe275f Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Fri, 19 Sep 2014 09:48:54 +0200 Subject: [PATCH 059/143] Add count argument for addParameterList --- MQ/include/MQ/PCF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQ/include/MQ/PCF.h b/MQ/include/MQ/PCF.h index 28235e9..49ccef2 100644 --- a/MQ/include/MQ/PCF.h +++ b/MQ/include/MQ/PCF.h @@ -59,7 +59,7 @@ class PCF : public Message void addParameter(MQLONG parameter, BufferPtr buffer); /// Add a byte string parameter. - void addParameterList(MQLONG parameter, MQLONG *values); + void addParameterList(MQLONG parameter, MQLONG *values, unsigned int count); /// Add a numeric list parameter. void addParameterList(MQLONG parameter, const std::vector& values); From d6c3abb3d08546c1ef217207c7038d72338dd009 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Fri, 19 Sep 2014 09:52:02 +0200 Subject: [PATCH 060/143] Add count argument to addParameterList --- MQ/src/PCF.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MQ/src/PCF.cpp b/MQ/src/PCF.cpp index 9cb40de..f359f1f 100644 --- a/MQ/src/PCF.cpp +++ b/MQ/src/PCF.cpp @@ -271,10 +271,9 @@ void PCF::addParameter(MQLONG parameter, BufferPtr value) header->ParameterCount++; } -void PCF::addParameterList(MQLONG parameter, MQLONG *values) +void PCF::addParameterList(MQLONG parameter, MQLONG *values, unsigned int count) { - int count = (sizeof values / sizeof values[0]); - int strucLength = MQCFIL_STRUC_LENGTH_FIXED + count * 4; + int strucLength = MQCFIL_STRUC_LENGTH_FIXED + count * sizeof(MQLONG); _pointers[parameter] = buffer().size(); buffer().resize(buffer().size() + strucLength); MQCFIL *pcfIntegerList = (MQCFIL *) &buffer()[_pointers[parameter]]; @@ -282,7 +281,7 @@ void PCF::addParameterList(MQLONG parameter, MQLONG *values) pcfIntegerList->Type = MQCFT_INTEGER_LIST; pcfIntegerList->StrucLength = strucLength; pcfIntegerList->Parameter = parameter; - pcfIntegerList->Values[0] = *values; + for(int i = 0; i < count; ++i) pcfIntegerList->Values[i] = values[i]; MQCFH* header = (MQCFH*) (MQBYTE*) &buffer()[0]; header->ParameterCount++; } From 8615fbfaa5a4981cccaed52875a4fb8008e50214 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 19 Sep 2014 18:32:06 +0200 Subject: [PATCH 061/143] Pass size() in addParameterList --- MQ/include/MQ/PCF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQ/include/MQ/PCF.h b/MQ/include/MQ/PCF.h index 49ccef2..76672e1 100644 --- a/MQ/include/MQ/PCF.h +++ b/MQ/include/MQ/PCF.h @@ -179,7 +179,7 @@ class PCF : public Message inline void PCF::addParameterList(MQLONG parameter, const std::vector& values) { - addParameterList(parameter, (MQLONG*) &values[0]); + addParameterList(parameter, (MQLONG*) &values[0], values.size()); } inline int PCF::getCommand() const From adfa615e3b8ac9765e2ea272b0c759739063a5d2 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 19 Sep 2014 19:14:41 +0200 Subject: [PATCH 062/143] Rename queue.pl / Add channel example --- samples/channel_inq.pl | 28 ++++++++++++++++++++++++++++ samples/pygmentize_samples.sh | 3 ++- samples/{queue.pl => queue_inq.pl} | 11 ++++++++--- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 samples/channel_inq.pl rename samples/{queue.pl => queue_inq.pl} (69%) diff --git a/samples/channel_inq.pl b/samples/channel_inq.pl new file mode 100644 index 0000000..d9d941a --- /dev/null +++ b/samples/channel_inq.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'ChannelName' => 'SYSTEM*', + 'ChannelAttrs' => [ + 'ChannelName', + 'ConnectionName' + ] +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/channel/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index 50f2a36..f4567e2 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -4,4 +4,5 @@ if [ -z "$1" ] echo "I need one argument: the root folder of the MQWeb GitHub pages" exit fi -pygmentize -o $1/api/samples/queue.html ./queue.pl +pygmentize -o $1/api/samples/queue_inq.html ./queue_inq.pl +pygmentize -o $1/api/samples/channel_inq.html ./channel_inq.pl diff --git a/samples/queue.pl b/samples/queue_inq.pl similarity index 69% rename from samples/queue.pl rename to samples/queue_inq.pl index ff78098..170bf27 100644 --- a/samples/queue.pl +++ b/samples/queue_inq.pl @@ -1,19 +1,24 @@ #!/usr/bin/perl use strict; use warnings; +use JSON; use LWP::UserAgent; use HTTP::Request::Common; my $qmgr = shift; die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); -my $json = '{ "QName" : "T*" }'; +my $json = JSON->new; + +my %input = ( + 'QName' => 'T*', +); my $ua = LWP::UserAgent->new; my $req = POST 'http://localhost:8081/api/queue/inquire/' . $qmgr; $req->header( 'Content-Type' => 'application/json' ); -$req->content($json); +$req->content($json->encode(\%input)); my $res = $ua->request($req); -print $res->content(); +print $json->pretty->encode($json->decode($res->content())); From 72ce6937228786d4060b5f78377fe67899c7ab87 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 19 Sep 2014 19:22:50 +0200 Subject: [PATCH 063/143] Renamed queue.php into queue_inq.php --- samples/{queue.php => queue_inq.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename samples/{queue.php => queue_inq.php} (100%) diff --git a/samples/queue.php b/samples/queue_inq.php similarity index 100% rename from samples/queue.php rename to samples/queue_inq.php From 182b4b384372745f57d89084181a6964aee5ff72 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 19 Sep 2014 19:23:02 +0200 Subject: [PATCH 064/143] Add queue_inq.php --- samples/pygmentize_samples.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index f4567e2..ea2f99b 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -4,5 +4,6 @@ if [ -z "$1" ] echo "I need one argument: the root folder of the MQWeb GitHub pages" exit fi -pygmentize -o $1/api/samples/queue_inq.html ./queue_inq.pl -pygmentize -o $1/api/samples/channel_inq.html ./channel_inq.pl +pygmentize -o $1/api/samples/queue_inq.pl.html ./queue_inq.pl +pygmentize -o $1/api/samples/queue_inq.php.html ./queue_inq.php +pygmentize -o $1/api/samples/channel_inq.pl.html ./channel_inq.pl From e770d7451a79d4bcbf1a62da0be9eb2e05835cc4 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 19 Sep 2014 22:56:35 +0200 Subject: [PATCH 065/143] Add authinfo sample --- samples/authinfo_inq.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 samples/authinfo_inq.php diff --git a/samples/authinfo_inq.php b/samples/authinfo_inq.php new file mode 100644 index 0000000..d83855e --- /dev/null +++ b/samples/authinfo_inq.php @@ -0,0 +1,16 @@ + Date: Fri, 19 Sep 2014 22:57:15 +0200 Subject: [PATCH 066/143] Add authinfo_inq.php and authreq_inq.pl samples --- samples/pygmentize_samples.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index ea2f99b..4548dce 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -4,6 +4,9 @@ if [ -z "$1" ] echo "I need one argument: the root folder of the MQWeb GitHub pages" exit fi + +pygmentize -o $1/api/samples/authinfo_inq.php.html ./authinfo_inq.php +pygmentize -o $1/api/samples/authrec_inq.pl.html ./authrec_inq.pl pygmentize -o $1/api/samples/queue_inq.pl.html ./queue_inq.pl pygmentize -o $1/api/samples/queue_inq.php.html ./queue_inq.php pygmentize -o $1/api/samples/channel_inq.pl.html ./channel_inq.pl From 67a43f8273e1169cfe62691223e6b834f3f3b60e Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 19 Sep 2014 22:57:30 +0200 Subject: [PATCH 067/143] Use JSON library --- samples/authrec_inq.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/samples/authrec_inq.pl b/samples/authrec_inq.pl index 142aec7..fdce1a0 100644 --- a/samples/authrec_inq.pl +++ b/samples/authrec_inq.pl @@ -1,19 +1,27 @@ #!/usr/bin/perl use strict; use warnings; +use JSON; use LWP::UserAgent; use HTTP::Request::Common; my $qmgr = shift; die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); -my $json = '{ "ProfileName" : "", "Options" : ["Name All Matching", "Entity Explicit"] }'; +my $json = JSON->new; + +my %input = ( + 'Options' => [ + 'Name All Matching', + 'Entity Explicit' + ] +); my $ua = LWP::UserAgent->new; my $req = POST 'http://localhost:8081/api/authrec/inquire/' . $qmgr; $req->header( 'Content-Type' => 'application/json' ); -$req->content($json); +$req->content($json->encode(\%input)); my $res = $ua->request($req); -print $res->content(); +print $json->pretty->encode($json->decode($res->content())); From 432aae021533f9dfa7613f820408c72524536e87 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 19 Sep 2014 22:57:58 +0200 Subject: [PATCH 068/143] Always use JSONView in exception handler --- MQWeb/src/MQController.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index e28446c..edeac56 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -168,15 +168,7 @@ void MQController::handleException(const MQException& mqe) reason->set("code", mqe.reason()); reason->set("desc", MQMapper::getReasonString(mqe.reason())); - if ( isJSON() ) - { - setJSONView(); - } - else - { - setView(new TemplateView("error.tpl")); - } - + setJSONView(); } From 418408b169a1b0334976dd61f5830be7f5d829e1 Mon Sep 17 00:00:00 2001 From: fbraem Date: Sun, 21 Sep 2014 22:21:32 +0200 Subject: [PATCH 069/143] Add more samples --- samples/authinfo_inq.pl | 24 ++++++++++++++++++++++++ samples/authrec_inq.php | 16 ++++++++++++++++ samples/channel_inq.php | 15 +++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 samples/authinfo_inq.pl create mode 100644 samples/authrec_inq.php create mode 100644 samples/channel_inq.php diff --git a/samples/authinfo_inq.pl b/samples/authinfo_inq.pl new file mode 100644 index 0000000..75ed5eb --- /dev/null +++ b/samples/authinfo_inq.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'AuthInfoName' => 'SYSTEM*' +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/authinfo/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); diff --git a/samples/authrec_inq.php b/samples/authrec_inq.php new file mode 100644 index 0000000..43c0856 --- /dev/null +++ b/samples/authrec_inq.php @@ -0,0 +1,16 @@ + Date: Sun, 21 Sep 2014 22:22:04 +0200 Subject: [PATCH 070/143] name is synonym for ChannelName --- MQWeb/src/ChannelController.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/MQWeb/src/ChannelController.cpp b/MQWeb/src/ChannelController.cpp index 2f5dbe6..ffbf1b6 100644 --- a/MQWeb/src/ChannelController.cpp +++ b/MQWeb/src/ChannelController.cpp @@ -62,8 +62,21 @@ void ChannelController::inquire() } else { - std::string channelNameField = form().get("ChannelName", "*"); - pcfParameters->set("ChannelName", channelNameField.empty() ? "*" : channelNameField); + // Handle query parameters + std::string channelNameField; + if ( form().has("ChannelName") ) + { + channelNameField = form().get("ChannelName"); + } + else if ( form().has("name") ) + { + channelNameField = form().get("name"); + } + if ( channelNameField.empty() ) + { + channelNameField = "*"; + } + pcfParameters->set("ChannelName", channelNameField); } if ( parameters.size() > 2 ) From 9c8407a313473f8ff8ad613bdf51c8daeadc6cc7 Mon Sep 17 00:00:00 2001 From: fbraem Date: Sun, 21 Sep 2014 22:22:21 +0200 Subject: [PATCH 071/143] Rearrange some parameters --- MQWeb/src/ChannelStatusController.cpp | 57 +++++++++++++++++++++------ MQWeb/src/ChannelStatusMapper.cpp | 13 ------ 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index 1a7828b..6197cb2 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -38,26 +38,57 @@ ChannelStatusController::~ChannelStatusController() void ChannelStatusController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a channelname and will result in inquiring - // only that channel. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("name", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - if ( form().has("name") ) filter->set("name", form().get("name")); - if ( form().has("channelType") ) filter->set("channelType", form().get("channelType")); - } + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a channelname and will result in inquiring + // only that channel. + if ( parameters.size() > 1 ) + { + pcfParameters->set("ChannelName", parameters[1]); + } + else + { + // Handle query parameters + std::string channelNameField; + if ( form().has("ChannelName") ) + { + channelNameField = form().get("ChannelName"); + } + else if ( form().has("name") ) + { + channelNameField = form().get("name"); + } + if ( channelNameField.empty() ) + { + channelNameField = "*"; + } + pcfParameters->set("ChannelName", channelNameField); + } - if ( form().has("instanceType") ) filter->set("instanceType", form().get("instanceType")); + if ( form().has("ChannelType") ) + { + Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + filter->set("Parameter", "ChannelType"); + filter->set("Operator", "EQ"); + filter->set("FilterValue", form().get("ChannelType")); + pcfParameters->set("StringFilterCommand", filter); + }; - ChannelStatusMapper channelStatusMapper(*commandServer(), filter); - set("statuses", channelStatusMapper.inquire()); + if ( form().has("InstanceType") ) pcfParameters->set("InstanceType", form().get("InstanceType")); + } + ChannelStatusMapper mapper(*commandServer(), pcfParameters); + set("statuses", mapper.inquire()); } diff --git a/MQWeb/src/ChannelStatusMapper.cpp b/MQWeb/src/ChannelStatusMapper.cpp index 73a448a..c1fa572 100644 --- a/MQWeb/src/ChannelStatusMapper.cpp +++ b/MQWeb/src/ChannelStatusMapper.cpp @@ -59,19 +59,6 @@ Poco::JSON::Array::Ptr ChannelStatusMapper::inquire() // Required parameters addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); - /*TODO: move to controller! - addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); - if ( filter->has("type") ) - { - std::string channelType = filter->optValue("type", "All"); - MQLONG channelTypeValue = dictionary()->getDisplayId(MQIACH_CHANNEL_TYPE, channelType); - poco_assert_dbg(channelTypeValue != -1); - if ( channelTypeValue != MQCHT_ALL ) - { - inquireChlStatus->addFilter(MQIACH_CHANNEL_TYPE, MQCFOP_EQUAL, channelTypeValue); - } - }*/ - // Optional parameters addParameterNumFromString(MQIACH_CHANNEL_DISP, "ChannelDisposition"); addParameter(MQCACH_CLIENT_ID, "ClientIdentifier"); From ba495c3eaa698904ba9ff2f48ad29f852cd8190d Mon Sep 17 00:00:00 2001 From: fbraem Date: Sun, 21 Sep 2014 22:22:29 +0200 Subject: [PATCH 072/143] Add more samples --- samples/pygmentize_samples.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index 4548dce..5232b45 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -6,7 +6,10 @@ if [ -z "$1" ] fi pygmentize -o $1/api/samples/authinfo_inq.php.html ./authinfo_inq.php +pygmentize -o $1/api/samples/authinfo_inq.pl.html ./authinfo_inq.pl +pygmentize -o $1/api/samples/authrec_inq.php.html ./authrec_inq.php pygmentize -o $1/api/samples/authrec_inq.pl.html ./authrec_inq.pl pygmentize -o $1/api/samples/queue_inq.pl.html ./queue_inq.pl pygmentize -o $1/api/samples/queue_inq.php.html ./queue_inq.php pygmentize -o $1/api/samples/channel_inq.pl.html ./channel_inq.pl +pygmentize -o $1/api/samples/channel_inq.php.html ./channel_inq.php From 5aee2dc3683f6ea310ca2ab0c1cd77381bf55281 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Mon, 22 Sep 2014 14:54:39 +0200 Subject: [PATCH 073/143] ChannelType must be a IntegerFilterCommand --- MQWeb/src/ChannelStatusController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index 6197cb2..fd4e649 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -82,7 +82,7 @@ void ChannelStatusController::inquire() filter->set("Parameter", "ChannelType"); filter->set("Operator", "EQ"); filter->set("FilterValue", form().get("ChannelType")); - pcfParameters->set("StringFilterCommand", filter); + pcfParameters->set("IntegerFilterCommand", filter); }; if ( form().has("InstanceType") ) pcfParameters->set("InstanceType", form().get("InstanceType")); From dad088373991bb8f12c7a0259d6471698cc6ec27 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Mon, 22 Sep 2014 15:40:26 +0200 Subject: [PATCH 074/143] Add chstatus example for Perl --- samples/chstatus_inq.pl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 samples/chstatus_inq.pl diff --git a/samples/chstatus_inq.pl b/samples/chstatus_inq.pl new file mode 100644 index 0000000..e842e46 --- /dev/null +++ b/samples/chstatus_inq.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'ChannelName' => '*', + 'IntegerFilterCommand' => { + 'Parameter' => 'ChannelType', + 'Operator' => 'EQ', + 'FilterValue' => 'Server-connection' + } +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/chstatus/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); From 9162e42ec47617707a981ad7379ad856dafdfbe3 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Mon, 22 Sep 2014 15:41:21 +0200 Subject: [PATCH 075/143] Add chstatus example for PHP --- samples/chstatus_inq.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 samples/chstatus_inq.php diff --git a/samples/chstatus_inq.php b/samples/chstatus_inq.php new file mode 100644 index 0000000..4502061 --- /dev/null +++ b/samples/chstatus_inq.php @@ -0,0 +1,15 @@ + Date: Mon, 22 Sep 2014 15:57:03 +0200 Subject: [PATCH 076/143] Add ChannelInstanceAttrs --- MQWeb/src/ChannelStatusController.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index fd4e649..2e30543 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -85,6 +85,17 @@ void ChannelStatusController::inquire() pcfParameters->set("IntegerFilterCommand", filter); }; + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("ChannelInstanceAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ChannelInstanceAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ChannelInstanceAttrs", attrs); + } + if ( form().has("InstanceType") ) pcfParameters->set("InstanceType", form().get("InstanceType")); } ChannelStatusMapper mapper(*commandServer(), pcfParameters); From 6ff6496acb576ba9bb96868fb4bc00a7e4b48067 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 22 Sep 2014 20:13:25 +0200 Subject: [PATCH 077/143] Add all missing query parameters --- MQWeb/src/ChannelStatusController.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index 2e30543..35d2ea3 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -97,6 +97,11 @@ void ChannelStatusController::inquire() } if ( form().has("InstanceType") ) pcfParameters->set("InstanceType", form().get("InstanceType")); + if ( form().has("ClientIdentifier") ) pcfParameters->set("ClientIdentifier"), form().get("ClientIdentifier")); + if ( form().has("ChannelInstanceType") ) pcfParameters->set("ChannelInstanceType"), form().get("ChannelInstanceType")); + if ( form().has("CommandScope") ) pcfParameters->set("CommandScope", form().get("CommandScope")); + if ( form().has("ConnectionName") ) pcfParameters->set("ConnectionName", form().get("ConnectionName")); + if ( form().has("XmitQName") ) pcfParameters->set("XmitQName", form().get("XmitQName")); } ChannelStatusMapper mapper(*commandServer(), pcfParameters); set("statuses", mapper.inquire()); From 28875c3e397d9e7c2fba7cee8ab915059e441b2e Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 22 Sep 2014 20:13:39 +0200 Subject: [PATCH 078/143] Add chstatus examples --- samples/pygmentize_samples.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index 5232b45..382ca46 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -13,3 +13,5 @@ pygmentize -o $1/api/samples/queue_inq.pl.html ./queue_inq.pl pygmentize -o $1/api/samples/queue_inq.php.html ./queue_inq.php pygmentize -o $1/api/samples/channel_inq.pl.html ./channel_inq.pl pygmentize -o $1/api/samples/channel_inq.php.html ./channel_inq.php +pygmentize -o $1/api/samples/chstatus_inq.pl.html ./chstatus_inq.pl +pygmentize -o $1/api/samples/chstatus_inq.php.html ./chstatus_inq.php From 502ee780956b12082b6b4a4f58b0b729737c8822 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 23 Sep 2014 19:06:15 +0200 Subject: [PATCH 079/143] Resize string to 0 when a parameter value starts with a null byte --- MQ/src/PCF.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MQ/src/PCF.cpp b/MQ/src/PCF.cpp index f359f1f..761eb53 100644 --- a/MQ/src/PCF.cpp +++ b/MQ/src/PCF.cpp @@ -91,6 +91,7 @@ std::string PCF::getParameterString(MQLONG parameter) const { MQCFST* pcfParam = (MQCFST*) &buffer()[it->second]; std::string result(pcfParam->String, pcfParam->StringLength); + if ( result[0] == '\0' ) result.resize(0); return Poco::trimRightInPlace(result); } else if ( *pcfType == MQCFT_BYTE_STRING ) From 00d413144733b7f72ddab59beb70e5ed6c26eeb3 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 23 Sep 2014 19:07:20 +0200 Subject: [PATCH 080/143] Add a way to not create id_nnnn properties --- MQWeb/include/MQ/Web/Dictionary.h | 2 +- MQWeb/src/Dictionary.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/MQWeb/include/MQ/Web/Dictionary.h b/MQWeb/include/MQ/Web/Dictionary.h index 09c0623..71ce493 100644 --- a/MQWeb/include/MQ/Web/Dictionary.h +++ b/MQWeb/include/MQ/Web/Dictionary.h @@ -61,7 +61,7 @@ class Dictionary bool hasDisplayMap(MQLONG id) const; /// Returns true when the id has a corresponding map with display values. - void mapToJSON(const PCF& pcf, Poco::JSON::Object::Ptr& json) const; + void mapToJSON(const PCF& pcf, Poco::JSON::Object::Ptr& json, bool alwaysCreate = true) const; std::map::const_iterator begin() const; /// Returns the begin iterator of the id map diff --git a/MQWeb/src/Dictionary.cpp b/MQWeb/src/Dictionary.cpp index 36de564..ed61b42 100644 --- a/MQWeb/src/Dictionary.cpp +++ b/MQWeb/src/Dictionary.cpp @@ -79,7 +79,7 @@ MQLONG Dictionary::getDisplayId(MQLONG id, const std::string& value) const return -1; } -void Dictionary::mapToJSON(const PCF& pcf, Poco::JSON::Object::Ptr& json) const +void Dictionary::mapToJSON(const PCF& pcf, Poco::JSON::Object::Ptr& json, bool alwaysCreate) const { std::vector parameters = pcf.getParameters(); for(std::vector::iterator it = parameters.begin(); it != parameters.end(); ++it) @@ -87,9 +87,18 @@ void Dictionary::mapToJSON(const PCF& pcf, Poco::JSON::Object::Ptr& json) const std::string name = getName(*it); if ( name.empty() ) { - name = "id_" + Poco::NumberFormatter::format(*it); + if ( alwaysCreate ) + { + name = "id_" + Poco::NumberFormatter::format(*it); + } + else + { + continue; + } } + if ( json->has(name) ) continue; // Don't overwrite already added properties + Poco::JSON::Object::Ptr field = new Poco::JSON::Object(); json->set(name, field); From 9b8111a18af9dac96bc2e38fda174fd0b4790d99 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 23 Sep 2014 19:09:34 +0200 Subject: [PATCH 081/143] Use the object type dictionary when the event has a MQIACF_OBJECT_TYPE parameter --- MQWeb/src/MessageController.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/MQWeb/src/MessageController.cpp b/MQWeb/src/MessageController.cpp index 7bb813b..8bf4f94 100644 --- a/MQWeb/src/MessageController.cpp +++ b/MQWeb/src/MessageController.cpp @@ -518,7 +518,7 @@ void MessageController::event() message.buffer().resize(DEFAULT_EVENT_MESSAGE_SIZE, false); try { - q.get(message, MQGMO_BROWSE_NEXT | MQGMO_CONVERT | MQGMO_ACCEPT_TRUNCATED_MSG); + q.get(message, MQGMO_BROWSE_NEXT | MQGMO_CONVERT); } catch(MQException& mqe) { @@ -527,8 +527,7 @@ void MessageController::event() if (! messageId.empty()) throw; break; } - else if ( mqe.reason() == MQRC_TRUNCATED_MSG_FAILED - || mqe.reason() == MQRC_TRUNCATED ) + else if ( mqe.reason() == MQRC_TRUNCATED_MSG_FAILED ) { message.buffer().resize(message.dataLength(), false); message.clear(); @@ -563,9 +562,29 @@ void MessageController::event() std::string reasonCodeStr = MQMapper::getReasonString(message.getReasonCode()); jsonReason->set("desc", reasonCodeStr); + if ( message.hasParameter(MQIACF_OBJECT_TYPE) ) + { + Poco::SharedPtr dictionary; + switch(message.getParameterNum(MQIACF_OBJECT_TYPE)) + { + case MQOT_Q_MGR: dictionary = MQMapper::dictionary("QueueManager"); break; + case MQOT_CHANNEL: dictionary = MQMapper::dictionary("Channel"); break; + case MQOT_NAMELIST: dictionary = MQMapper::dictionary("Namelist"); break; + case MQOT_PROCESS: dictionary = MQMapper::dictionary("Process"); break; + case MQOT_Q: dictionary = MQMapper::dictionary("Queue"); break; + case MQOT_LISTENER: dictionary = MQMapper::dictionary("Listener"); break; + default: + Poco::Logger::get("mq.web").warning("No dictionary set for event. ObjectType $0", message.getParameterNum(MQIACF_OBJECT_TYPE)); + } + if ( !dictionary.isNull() ) + { + dictionary->mapToJSON(message, jsonEvent, false); + } + } + Poco::SharedPtr dictionary = MQMapper::dictionary("Event"); poco_assert_dbg(! dictionary.isNull()); - dictionary->mapToJSON(message, jsonEvent); + dictionary->mapToJSON(message, jsonEvent, false); count++; } From e8d8ab2434495a39d9cb32d3b3807747d3517c35 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 23 Sep 2014 19:09:48 +0200 Subject: [PATCH 082/143] Solve compiler errors --- MQWeb/src/ChannelStatusController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index 35d2ea3..c4e1f64 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -97,8 +97,8 @@ void ChannelStatusController::inquire() } if ( form().has("InstanceType") ) pcfParameters->set("InstanceType", form().get("InstanceType")); - if ( form().has("ClientIdentifier") ) pcfParameters->set("ClientIdentifier"), form().get("ClientIdentifier")); - if ( form().has("ChannelInstanceType") ) pcfParameters->set("ChannelInstanceType"), form().get("ChannelInstanceType")); + if ( form().has("ClientIdentifier") ) pcfParameters->set("ClientIdentifier", form().get("ClientIdentifier")); + if ( form().has("ChannelInstanceType") ) pcfParameters->set("ChannelInstanceType", form().get("ChannelInstanceType")); if ( form().has("CommandScope") ) pcfParameters->set("CommandScope", form().get("CommandScope")); if ( form().has("ConnectionName") ) pcfParameters->set("ConnectionName", form().get("ConnectionName")); if ( form().has("XmitQName") ) pcfParameters->set("XmitQName", form().get("XmitQName")); From a4a814c416e232217cb837a516487030f5b20e11 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 23 Sep 2014 19:38:30 +0200 Subject: [PATCH 083/143] Add missing parameters --- MQWeb/src/ClusterQueueManagerController.cpp | 63 ++++++++++++++++----- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/MQWeb/src/ClusterQueueManagerController.cpp b/MQWeb/src/ClusterQueueManagerController.cpp index 957b805..bf61d34 100644 --- a/MQWeb/src/ClusterQueueManagerController.cpp +++ b/MQWeb/src/ClusterQueueManagerController.cpp @@ -39,26 +39,63 @@ ClusterQueueManagerController::~ClusterQueueManagerController() void ClusterQueueManagerController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter is a clustername - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("clusterName", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - std::string clusterNameField = form().get("clusterName", "*"); - filter->set("clusterName", clusterNameField.empty() ? "*" : clusterNameField); - std::string clusterQmgrNameField = form().get("clusterQmgrName", "*"); - filter->set("clusterQmgrName", clusterQmgrNameField.empty() ? "*" : clusterQmgrNameField); - std::string channelNameField = form().get("channelName", "*"); - filter->set("channelName", channelNameField.empty() ? "*" : channelNameField); + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter is a clustername + if ( parameters.size() > 1 ) + { + pcfParameters->set("ClusterName", parameters[1]); + } + else + { + std::string clusterNameField; + if ( form().has("ClusterName") ) + { + clusterNameField = form().get("ClusterName"); + } + else if ( form().has("name") ) + { + clusterNameField = form().get("name"); + } + if ( !clusterNameField.empty() ) + { + pcfParameters->set("ClusterName", clusterNameField); + } + } + + std::string clusterQmgrNameField = form().get("ClusterQmgrName", "*"); + pcfParameters->set("ClusterQmgrName", clusterQmgrNameField.empty() ? "*" : clusterQmgrNameField); + + if ( form().has("ChannelName") ) pcfParameters->set("ChannelName", form().get("ChannelName")); + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("ClusterQMgrAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ClusterQMgrAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ClusterQMgrAttrs", attrs); + } + + if ( form().has("CommandScope") ) pcfParameters->set("CommandScope", form().get("CommandScope")); + + handleFilterForm(pcfParameters); } - ClusterQueueManagerMapper mapper(*commandServer(), filter); + ClusterQueueManagerMapper mapper(*commandServer(), pcfParameters); set("clusqmgrs", mapper.inquire()); } From 0b454e16d4b2184897835ed978cd4193244032b4 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 23 Sep 2014 19:39:01 +0200 Subject: [PATCH 084/143] Add handleFilterForm to handle IntegerFilterCommand / StringFilterCommand --- MQWeb/src/ChannelStatusController.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MQWeb/src/ChannelStatusController.cpp b/MQWeb/src/ChannelStatusController.cpp index c4e1f64..6664a39 100644 --- a/MQWeb/src/ChannelStatusController.cpp +++ b/MQWeb/src/ChannelStatusController.cpp @@ -102,6 +102,8 @@ void ChannelStatusController::inquire() if ( form().has("CommandScope") ) pcfParameters->set("CommandScope", form().get("CommandScope")); if ( form().has("ConnectionName") ) pcfParameters->set("ConnectionName", form().get("ConnectionName")); if ( form().has("XmitQName") ) pcfParameters->set("XmitQName", form().get("XmitQName")); + + handleFilterForm(pcfParameters); } ChannelStatusMapper mapper(*commandServer(), pcfParameters); set("statuses", mapper.inquire()); From c10bdbafdb41878b7eda68c13cfa06e109f98f4f Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Wed, 24 Sep 2014 16:03:03 +0200 Subject: [PATCH 085/143] Add clusqmgr_inq.pl sample --- samples/clusqmgr_inq.pl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 samples/clusqmgr_inq.pl diff --git a/samples/clusqmgr_inq.pl b/samples/clusqmgr_inq.pl new file mode 100644 index 0000000..7416c03 --- /dev/null +++ b/samples/clusqmgr_inq.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'ClusterQmgrName' => '*', + 'ClusterName' => 'SONGBIRDS' +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/clusqmgr/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); From 6ef05dee2993c580308e6506a249ab794f83a5a4 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 24 Sep 2014 18:19:43 +0200 Subject: [PATCH 086/143] Add MQCOMPRESS_NOT_AVAILABLE and MQIA_USE_DEAD_LETTER_Q (clusqmgr) --- MQDictionary/src/Application.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index f00163f..65f73b0 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -794,6 +794,7 @@ Dictionary channelDictionary = Dictionary() (MQCOMPRESS_ZLIBHIGH, "Zlib High") (MQCOMPRESS_ANY, "Any") (MQCOMPRESS_SYSTEM, "System") + (MQCOMPRESS_NOT_AVAILABLE, "Not Available") ) (MQIACH_HB_INTERVAL, "HeartbeatInterval") #ifdef MQIACH_IN_DOUBT @@ -1178,6 +1179,9 @@ Dictionary clusterQueueManagerDictionary = Dictionary() (MQCACH_TP_NAME) (MQCA_XMIT_Q_NAME) (MQIACH_XMIT_PROTOCOL_TYPE) +#ifdef MQIA_USE_DEAD_LETTER_Q + (MQIA_USE_DEAD_LETTER_Q) +#endif (MQCACH_USER_ID) // Extended Response (MQBACF_RESPONSE_ID) From 91d31b45fcaa362b0e039329706558d3063ee309 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 25 Sep 2014 10:29:26 +0200 Subject: [PATCH 087/143] Add URL parameter for ClusterQMgrName --- MQWeb/src/ClusterQueueManagerController.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MQWeb/src/ClusterQueueManagerController.cpp b/MQWeb/src/ClusterQueueManagerController.cpp index bf61d34..66e8640 100644 --- a/MQWeb/src/ClusterQueueManagerController.cpp +++ b/MQWeb/src/ClusterQueueManagerController.cpp @@ -53,6 +53,7 @@ void ClusterQueueManagerController::inquire() std::vector parameters = getParameters(); // First parameter is queuemanager // Second parameter is a clustername + // Third parameter is a cluster queuemanager if ( parameters.size() > 1 ) { pcfParameters->set("ClusterName", parameters[1]); @@ -74,8 +75,15 @@ void ClusterQueueManagerController::inquire() } } - std::string clusterQmgrNameField = form().get("ClusterQmgrName", "*"); - pcfParameters->set("ClusterQmgrName", clusterQmgrNameField.empty() ? "*" : clusterQmgrNameField); + if ( parameters.size() > 2 ) + { + pcfParameters->set("ClusterQMgrName", parameters[2]); + } + else + { + std::string clusterQmgrNameField = form().get("ClusterQMgrName", "*"); + pcfParameters->set("ClusterQMgrName", clusterQmgrNameField.empty() ? "*" : clusterQmgrNameField); + } if ( form().has("ChannelName") ) pcfParameters->set("ChannelName", form().get("ChannelName")); From a8b31c7cb7c43febeb41160e64d0c19ccc9dc62f Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 25 Sep 2014 10:30:08 +0200 Subject: [PATCH 088/143] ClusterQMgrName --- MQWeb/src/ClusterQueueManagerMapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQWeb/src/ClusterQueueManagerMapper.cpp b/MQWeb/src/ClusterQueueManagerMapper.cpp index 3a87f76..3744ae8 100644 --- a/MQWeb/src/ClusterQueueManagerMapper.cpp +++ b/MQWeb/src/ClusterQueueManagerMapper.cpp @@ -57,7 +57,7 @@ Poco::JSON::Array::Ptr ClusterQueueManagerMapper::inquire() createCommand(MQCMD_INQUIRE_CLUSTER_Q_MGR); // Required parameters - addParameter(MQCA_CLUSTER_Q_MGR_NAME, "ClusterQmgrName"); + addParameter(MQCA_CLUSTER_Q_MGR_NAME, "ClusterQMgrName"); // Optional parameters addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); From 67c89d6c221776ecd370140141c5739c16be7716 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 25 Sep 2014 11:02:49 +0200 Subject: [PATCH 089/143] Add more parameters --- MQWeb/src/ConnectionController.cpp | 54 +++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/MQWeb/src/ConnectionController.cpp b/MQWeb/src/ConnectionController.cpp index 8d55a10..8019e2d 100644 --- a/MQWeb/src/ConnectionController.cpp +++ b/MQWeb/src/ConnectionController.cpp @@ -39,18 +39,56 @@ ConnectionController::~ConnectionController() void ConnectionController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a connection id and will result in inquiring - // only that connection. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("id", parameters[1]); + pcfParameters = data().getObject("filter"); + } + else + { + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a connection id and will result in inquiring + // only that connection. + if ( parameters.size() > 1 ) + { + pcfParameters->set("ConnectionId", parameters[1]); + } + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("ConnectionAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ConnectionAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ConnectionAttrs", attrs); + } + + if ( form().has("CommandScope") ) + { + pcfParameters->set("CommandScope", form().get("CommandScope")); + } + + if ( form().has("ConnInfoType") ) + { + pcfParameters->set("ConnInfoType", form().get("ConnInfoType")); + } + + if ( form().has("URDisposition") ) + { + pcfParameters->set("URDisposition", form().get("URDisposition")); + } + + handleFilterForm(pcfParameters); } - ConnectionMapper mapper(*commandServer(), filter); + ConnectionMapper mapper(*commandServer(), pcfParameters); set("connections", mapper.inquire()); } From d9009c326ff3cfa720a0d855e7872b0599b25d38 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 25 Sep 2014 12:27:49 +0200 Subject: [PATCH 090/143] Rename MQIACF_CONN_INFO_TYPE values --- MQDictionary/src/Application.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 65f73b0..a5d2a47 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -1192,8 +1192,9 @@ Dictionary connectionDictionary = Dictionary() (MQIA_APPL_TYPE) (MQBACF_CONNECTION_ID, "ConnectionId") (MQIACF_CONN_INFO_TYPE, "ConnInfoType", DisplayMapInitializer - (MQIACF_CONN_INFO_CONN, "Generic Information") - (MQIACF_CONN_INFO_HANDLE, "Connection Information") + (MQIACF_CONN_INFO_CONN, "Connection") + (MQIACF_CONN_INFO_HANDLE, "Handle") + (MQIACF_CONN_INFO_ALL, "All") ) (MQBACF_GENERIC_CONNECTION_ID, "GenericConnectionId") // Extended Response From 7dfd3b15bbc12dbd3daa0c8f8a978e5e64c2a3c8 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 26 Sep 2014 18:27:27 +0200 Subject: [PATCH 091/143] Add connection attributes --- MQDictionary/src/Application.cpp | 76 ++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index a5d2a47..35a9264 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -666,6 +666,9 @@ Dictionary queueStatusDictionary = Dictionary() (MQAS_SUSPENDED, "Suspended") (MQAS_SUSPENDED_TEMPORARY, "Suspended Temporary") (MQAS_NONE, "None") + (MQAS_STARTED, "Started") + (MQAS_START_WAIT, "Start Wait") + (MQAS_STOPPED, "Stopped") ) (MQCACH_CHANNEL_NAME, "ChannelName") (MQCACH_CONNECTION_NAME) @@ -687,7 +690,7 @@ Dictionary queueStatusDictionary = Dictionary() (MQQSO_YES, "Yes") (MQQSO_NO, "No") ) - (MQIACF_OPEN_OPTIONS, "") + (MQIACF_OPEN_OPTIONS, "OpenOptions") (MQIACF_OPEN_OUTPUT, "OpenOutput", DisplayMapInitializer (MQQSO_YES, "Yes") (MQQSO_NO, "No") @@ -1092,7 +1095,7 @@ Dictionary clusterQueueManagerDictionary = Dictionary() (MQIACH_CLWL_CHANNEL_PRIORITY, "CLWLChannelPriority") (MQIACH_CLWL_CHANNEL_RANK, "CLWLChannelRank") (MQIACH_CLWL_CHANNEL_WEIGHT, "CLWLChannelWeight") - (MQCACH_CONNECTION_NAME, "ConnectionName") + (MQCACH_CONNECTION_NAME) (MQIACH_DATA_CONVERSION, "DataConversion", DisplayMapInitializer (MQCDC_NO_SENDER_CONVERSION, "No") (MQCDC_SENDER_CONVERSION, "Sender") @@ -1189,14 +1192,71 @@ Dictionary clusterQueueManagerDictionary = Dictionary() ; Dictionary connectionDictionary = Dictionary() + (MQCACF_APPL_DESC) + (MQCACF_APPL_TAG) (MQIA_APPL_TYPE) + (MQCACF_ASID) + (MQIACF_ASYNC_STATE) + (MQCACH_CHANNEL_NAME) (MQBACF_CONNECTION_ID, "ConnectionId") + (MQCACH_CONNECTION_NAME) + (MQIACF_CONNECT_OPTIONS, "ConnectOptions") (MQIACF_CONN_INFO_TYPE, "ConnInfoType", DisplayMapInitializer (MQIACF_CONN_INFO_CONN, "Connection") (MQIACF_CONN_INFO_HANDLE, "Handle") (MQIACF_CONN_INFO_ALL, "All") ) + (MQCACF_DESTINATION, "Destination") + (MQCACF_DESTINATION_Q_MGR, "DestinationQueueManager") (MQBACF_GENERIC_CONNECTION_ID, "GenericConnectionId") + (MQIACF_HANDLE_STATE, "HandleState", DisplayMapInitializer + (MQHSTATE_ACTIVE, "Active") + (MQHSTATE_INACTIVE, "Inactive") + ) + (MQCACF_OBJECT_NAME) + (MQIACF_OBJECT_TYPE) + (MQIACF_OPEN_OPTIONS) + (MQCACF_ORIGIN_NAME, "OriginName") + (MQBACF_ORIGIN_UOW_ID, "OriginUOWId") + (MQIACF_PROCESS_ID) + (MQCACF_PSB_NAME) + (MQCACF_PST_ID) + (MQBACF_Q_MGR_UOW_ID, "QMgrUOWId") + (MQIA_QSG_DISP) + (MQIA_READ_AHEAD, "ReadAhead", DisplayMapInitializer + (MQREADA_NO, "No") + (MQREADA_YES, "Yes") + (MQREADA_BACKLOG, "Backlog") + (MQREADA_INHIBITED, "Inhibited") + ) + (MQCACF_UOW_LOG_EXTENT_NAME, "StartUOWLogExtent") + (MQBACF_SUB_ID, "SubscriptionID") + (MQCACF_SUB_NAME, "SubscriptionName") + (MQIACF_THREAD_ID) + (MQCA_TOPIC_STRING, "TopicString") + (MQCACF_TRANSACTION_ID) + (MQBACF_EXTERNAL_UOW_ID, "UOWIdentifier") + (MQCACF_UOW_LOG_START_DATE, "UOWLogStartDate") + (MQCACF_UOW_LOG_START_TIME, "UOWLogStartTime") + (MQCACF_UOW_START_DATE, "UOWStartDate") + (MQCACF_UOW_START_TIME, "UOWStartTime") + (MQIACF_UOW_STATE, "UOWState", DisplayMapInitializer + (MQUOWST_NONE, "None") + (MQUOWST_ACTIVE, "Active") + (MQUOWST_PREPARED, "Prepared") + (MQUOWST_UNRESOLVED, "Unresolved") + ) + (MQIACF_UOW_TYPE, "UOWType", DisplayMapInitializer + (MQUOWT_Q_MGR, "Queuemanager") + (MQUOWT_CICS, "CICS") + (MQUOWT_RRS, "RRS") + (MQUOWT_IMS, "IMS") + (MQUOWT_XA, "XA") + ) + (MQIA_UR_DISP, "URDisposition", DisplayMapInitializer + (MQQSGD_GROUP, "Group") + (MQQSGD_Q_MGR, "Queuemanager") + ) // Extended Response (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") @@ -1214,7 +1274,7 @@ Dictionary listenerDictionary = Dictionary() (MQCACH_LOCAL_NAME, "LocalName") (MQIACH_NAME_COUNT, "NetbiosNames") (MQIACH_PORT, "Port") - (MQIACF_PROCESS_ID, "ProcessId") + (MQIACF_PROCESS_ID) (MQIACH_SESSION_COUNT, "Sessions") (MQIACH_SOCKET, "Socket") (MQIACH_LISTENER_CONTROL, "StartMode", DisplayMapInitializer @@ -1239,7 +1299,7 @@ Dictionary listenerStatusDictionary = Dictionary() (MQCACH_LOCAL_NAME, "LocalName") (MQIACH_NAME_COUNT, "NetbiosNames") (MQIACH_PORT, "Port") - (MQIACF_PROCESS_ID, "ProcessId") + (MQIACF_PROCESS_ID) (MQIACH_SOCKET, "Socket") (MQIACH_LISTENER_CONTROL, "StartMode", DisplayMapInitializer (MQSVC_CONTROL_MANUAL, "Manual") @@ -1322,7 +1382,7 @@ Dictionary topicDictionary = Dictionary() ) (MQCA_TOPIC_DESC, "TopicDesc") (MQCA_TOPIC_NAME, "TopicName") - (MQCA_TOPIC_STRING, "TopicString") + (MQCA_TOPIC_STRING) (MQIA_TOPIC_TYPE, "TopicType", DisplayMapInitializer (MQTOPT_LOCAL, "All") (MQTOPT_LOCAL, "Local") @@ -1555,7 +1615,7 @@ Dictionary eventDictionary = Dictionary() (MQGACF_COMMAND_DATA, "CommandData") (MQCACF_COMMAND_MQSC, "CommandMQSC") (MQCA_COMM_INFO_NAME, "CommInfoName") - (MQCACH_CONNECTION_NAME, "ConnectionName") + (MQCACH_CONNECTION_NAME) (MQIACF_CONV_REASON_CODE, "ConversionReasonCode", DisplayMapInitializer MQCONST2STR(MQRC_CONVERTED_MSG_TOO_BIG) MQCONST2STR(MQRC_FORMAT_ERROR) @@ -1669,7 +1729,7 @@ Dictionary eventDictionary = Dictionary() (MQOT_SHORT_CHANNEL, "Short Channel") (MQOT_PROT_POLICY, "Protection Policy") ) - (MQIACF_OPEN_OPTIONS, "OpenOptions") + (MQIACF_OPEN_OPTIONS) (MQCA_PROCESS_NAME, "ProcessName") (MQCA_Q_NAME, "QName") (MQCA_Q_MGR_NAME) @@ -1683,7 +1743,7 @@ Dictionary eventDictionary = Dictionary() (MQIACF_SUB_OPTIONS, "SubOptions") (MQIA_TIME_SINCE_RESET, "TimeSinceReset") (MQCA_TOPIC_NAME, "TopicName") - (MQCA_TOPIC_STRING, "TopicString") + (MQCA_TOPIC_STRING) (MQIACF_REASON_QUALIFIER, "ReasonQualifier", DisplayMapInitializer (MQRQ_CONN_NOT_AUTHORIZED, "Conn Not Authorized") (MQRQ_OPEN_NOT_AUTHORIZED, "Open Not Authorized") From 535118193eaead2034fdcaa3c28e5faaaf395c89 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 26 Sep 2014 18:28:12 +0200 Subject: [PATCH 092/143] Set MQIACF_CONNECTION_ATTRS to MQIACF_ALL when no ConnectionAttrs property exists --- MQWeb/src/ConnectionMapper.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MQWeb/src/ConnectionMapper.cpp b/MQWeb/src/ConnectionMapper.cpp index c9d54b6..72e7998 100644 --- a/MQWeb/src/ConnectionMapper.cpp +++ b/MQWeb/src/ConnectionMapper.cpp @@ -91,6 +91,14 @@ Poco::JSON::Array::Ptr ConnectionMapper::inquire() addStringFilter(); addParameterNumFromString(MQIA_UR_DISP, "URDisposition"); + if ( ! _input->has("ConnectionAttrs") ) + { + // It seems that this is not set by default, so we do + // it ourselves. + MQLONG attrs[] = { MQIACF_ALL }; + pcf()->addParameterList(MQIACF_CONNECTION_ATTRS, attrs, 1); + } + PCF::Vector commandResponse; execute(commandResponse); From 455f599d189ce453fd371e788279f8e91824ca8e Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 26 Sep 2014 18:31:04 +0200 Subject: [PATCH 093/143] Add inquire connection sample --- samples/conn_inq.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 samples/conn_inq.pl diff --git a/samples/conn_inq.pl b/samples/conn_inq.pl new file mode 100644 index 0000000..003ed24 --- /dev/null +++ b/samples/conn_inq.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/conn/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); From 76775486cfeaacc22b4a83317d1501f0bcfe6d30 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Wed, 1 Oct 2014 10:20:28 +0200 Subject: [PATCH 094/143] Add MQQSGD_ALL to MQIA_UR_DISP --- MQDictionary/src/Application.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 35a9264..6a26df3 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -1254,6 +1254,7 @@ Dictionary connectionDictionary = Dictionary() (MQUOWT_XA, "XA") ) (MQIA_UR_DISP, "URDisposition", DisplayMapInitializer + (MQQSGD_ALL, "All") (MQQSGD_GROUP, "Group") (MQQSGD_Q_MGR, "Queuemanager") ) From 953045ab053973c12b0bbb1277e8eb0dcfc1fce6 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 1 Oct 2014 22:04:30 +0200 Subject: [PATCH 095/143] Add new samples --- samples/clusqmgr_inq.php | 15 +++++++++++++++ samples/conn_inq.php | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 samples/clusqmgr_inq.php create mode 100644 samples/conn_inq.php diff --git a/samples/clusqmgr_inq.php b/samples/clusqmgr_inq.php new file mode 100644 index 0000000..1944a7f --- /dev/null +++ b/samples/clusqmgr_inq.php @@ -0,0 +1,15 @@ + Date: Wed, 1 Oct 2014 22:05:59 +0200 Subject: [PATCH 096/143] Add MQQSGD_ALL for URDisposition --- MQDictionary/src/Application.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 35a9264..afb0a7a 100644 --- a/MQDictionary/src/Application.cpp +++ b/MQDictionary/src/Application.cpp @@ -1254,6 +1254,7 @@ Dictionary connectionDictionary = Dictionary() (MQUOWT_XA, "XA") ) (MQIA_UR_DISP, "URDisposition", DisplayMapInitializer + (MQQSGD_ALL, "All") (MQQSGD_GROUP, "Group") (MQQSGD_Q_MGR, "Queuemanager") ) From bcdfc434e16bce686ba141b0c16d6972603f3f50 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 1 Oct 2014 22:06:52 +0200 Subject: [PATCH 097/143] Add new URL / Query parameters --- MQWeb/src/ListenerController.cpp | 68 ++++++++++++++---- MQWeb/src/ListenerStatusController.cpp | 58 +++++++++++---- MQWeb/src/ListenerStatusMapper.cpp | 9 +++ MQWeb/src/NamelistController.cpp | 77 +++++++++++++++++--- MQWeb/src/NamelistMapper.cpp | 1 + MQWeb/src/ProcessController.cpp | 69 +++++++++++++++--- MQWeb/src/QueueController.cpp | 15 ++-- MQWeb/src/QueueManagerController.cpp | 29 +++++++- MQWeb/src/QueueManagerStatusController.cpp | 25 ++++++- MQWeb/src/QueueStatusController.cpp | 82 +++++++++++++++++----- MQWeb/src/ServiceController.cpp | 59 +++++++++++++--- 11 files changed, 402 insertions(+), 90 deletions(-) diff --git a/MQWeb/src/ListenerController.cpp b/MQWeb/src/ListenerController.cpp index 925223a..b2064a5 100644 --- a/MQWeb/src/ListenerController.cpp +++ b/MQWeb/src/ListenerController.cpp @@ -39,31 +39,69 @@ ListenerController::~ListenerController() void ListenerController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a listenername and will result in inquiring - // only that listener and ignores all query parameters. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("name", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - // Handle query parameters - std::string listenerNameField = form().get("listenerName", "*"); - if ( listenerNameField.empty() ) + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a listenername and will result in inquiring + // only that listener. + if ( parameters.size() > 1 ) + { + pcfParameters->set("ListenerName", parameters[1]); + } + else + { + std::string listenerNameField; + if ( form().has("ListenerName") ) + { + listenerNameField = form().get("ListenerName"); + } + else if ( form().has("name") ) + { + listenerNameField = form().get("name"); + } + if ( listenerNameField.empty() ) + { + listenerNameField = "*"; + } + pcfParameters->set("ListenerName", listenerNameField); + } + + if ( parameters.size() > 2 ) + { + pcfParameters->set("TransportType", parameters[2]); + } + else if ( form().has("TransportType") ) + { + pcfParameters->set("TransportType", form().get("TransportType")); + } + + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("ListenerAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ListenerAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) { - listenerNameField = "*"; + pcfParameters->set("ListenerAttrs", attrs); } - filter->set("name", listenerNameField); - filter->set("type", form().get("listenerType", "All")); - filter->set("excludeSystem", form().get("listenerExcludeSystem", "false").compare("true") == 0); + handleFilterForm(pcfParameters); } - ListenerMapper mapper(*commandServer(), filter); + ListenerMapper mapper(*commandServer(), pcfParameters); set("listeners", mapper.inquire()); } diff --git a/MQWeb/src/ListenerStatusController.cpp b/MQWeb/src/ListenerStatusController.cpp index e84a5d2..b5d4ebf 100644 --- a/MQWeb/src/ListenerStatusController.cpp +++ b/MQWeb/src/ListenerStatusController.cpp @@ -39,28 +39,60 @@ ListenerStatusController::~ListenerStatusController() void ListenerStatusController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a listenername and will result in inquiring - // only that listener and ignores all query parameters. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("name", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - // Handle query parameters - std::string listenerNameField = form().get("listenerName", "*"); - if ( listenerNameField.empty() ) + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a listenername and will result in inquiring + // only that listener. + if ( parameters.size() > 1 ) + { + pcfParameters->set("ListenerName", parameters[1]); + } + else { - listenerNameField = "*"; + std::string listenerNameField; + if ( form().has("ListenerName") ) + { + listenerNameField = form().get("ListenerName"); + } + else if ( form().has("name") ) + { + listenerNameField = form().get("name"); + } + if ( listenerNameField.empty() ) + { + listenerNameField = "*"; + } + pcfParameters->set("ListenerName", listenerNameField); } - filter->set("name", listenerNameField); } - ListenerStatusMapper mapper(*commandServer(), filter); + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("ListenerStatusAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ListenerStatusAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ListenerStatusAttrs", attrs); + } + + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + + handleFilterForm(pcfParameters); + + ListenerStatusMapper mapper(*commandServer(), pcfParameters); set("statuses", mapper.inquire()); } diff --git a/MQWeb/src/ListenerStatusMapper.cpp b/MQWeb/src/ListenerStatusMapper.cpp index 2381fee..cf3d650 100644 --- a/MQWeb/src/ListenerStatusMapper.cpp +++ b/MQWeb/src/ListenerStatusMapper.cpp @@ -66,6 +66,8 @@ Poco::JSON::Array::Ptr ListenerStatusMapper::inquire() PCF::Vector commandResponse; execute(commandResponse); + bool excludeSystem = _input->optValue("ExcludeSystem", false); + Poco::JSON::Array::Ptr statuses = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { @@ -75,6 +77,13 @@ Poco::JSON::Array::Ptr ListenerStatusMapper::inquire() if ( (*it)->getReasonCode() != MQRC_NONE ) continue; + std::string listenerName = (*it)->getParameterString(MQCACH_LISTENER_NAME); + if ( excludeSystem + && listenerName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } + statuses->add(createJSON(**it)); } diff --git a/MQWeb/src/NamelistController.cpp b/MQWeb/src/NamelistController.cpp index ca6034c..4c7a1b0 100644 --- a/MQWeb/src/NamelistController.cpp +++ b/MQWeb/src/NamelistController.cpp @@ -39,24 +39,79 @@ NamelistController::~NamelistController() void NamelistController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a namelistname and will result in inquiring - // only that namelist. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("name", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - std::string namelistNameField = form().get("namelistName", "*"); - filter->set("name", namelistNameField.empty() ? "*" : namelistNameField); - filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a namelistname and will result in inquiring + // only that namelist. + if ( parameters.size() > 1 ) + { + pcfParameters->set("NamelistName", parameters[1]); + } + else + { + std::string namelistNameField; + if ( form().has("NamelistName") ) + { + namelistNameField = form().get("NamelistName"); + } + else if ( form().has("name") ) + { + namelistNameField = form().get("name"); + } + if ( namelistNameField.empty() ) + { + namelistNameField = "*"; + } + pcfParameters->set("NamelistName", namelistNameField); + } + + if ( parameters.size() > 2 ) + { + pcfParameters->set("NamelistType", parameters[2]); + } + else if ( form().has("NamelistType") ) + { + pcfParameters->set("NamelistType", form().get("NamelistType")); + } + } + + if ( form().has("CommandScope") ) + { + pcfParameters->set("CommandScope", form().get("CommandScope")); + } + + if ( form().has("QSGDisposition") ) + { + pcfParameters->set("QSGDisposition", form().get("QSGDisposition")); } - NamelistMapper mapper(*commandServer(), filter); + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("NamelistAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ListenerStatusAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("NamelistAttrs", attrs); + } + + handleFilterForm(pcfParameters); + + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + + NamelistMapper mapper(*commandServer(), pcfParameters); set("namelists", mapper.inquire()); } diff --git a/MQWeb/src/NamelistMapper.cpp b/MQWeb/src/NamelistMapper.cpp index 215f9b8..c9e2318 100644 --- a/MQWeb/src/NamelistMapper.cpp +++ b/MQWeb/src/NamelistMapper.cpp @@ -63,6 +63,7 @@ Poco::JSON::Array::Ptr NamelistMapper::inquire() addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); addIntegerFilter(); addAttributeList(MQIACF_NAMELIST_ATTRS, "NamelistAttrs"); + addParameterNumFromString(MQIA_NAMELIST_TYPE, "NamelistType"); addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); addStringFilter(); diff --git a/MQWeb/src/ProcessController.cpp b/MQWeb/src/ProcessController.cpp index 3da2810..9ca77b6 100644 --- a/MQWeb/src/ProcessController.cpp +++ b/MQWeb/src/ProcessController.cpp @@ -39,24 +39,71 @@ ProcessController::~ProcessController() void ProcessController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a processname and will result in inquiring - // only that process. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("name", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - std::string processNameField = form().get("processName", "*"); - filter->set("name", processNameField.empty() ? "*" : processNameField); - filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a processname. If this is passed + // the query parameter ProcessName is ignored. + if ( parameters.size() > 1 ) + { + pcfParameters->set("ProcessName", parameters[1]); + } + else + { + // Handle query parameters + std::string processNameField; + if ( form().has("ProcessName") ) + { + processNameField = form().get("ProcessName"); + } + else if ( form().has("name") ) + { + processNameField = form().get("name"); + } + if ( processNameField.empty() ) + { + processNameField = "*"; + } + pcfParameters->set("ProcessName", processNameField); + } + + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("ProcessAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ProcessAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ProcessAttrs", attrs); + } + + if ( form().has("CommandScope") ) + { + pcfParameters->set("CommandScope", form().get("CommandScope")); + } + + if ( form().has("QSGDisposition") ) + { + pcfParameters->set("QSGDisposition", form().get("QSGDisposition")); + } + + handleFilterForm(pcfParameters); } - ProcessMapper mapper(*commandServer(), filter); + ProcessMapper mapper(*commandServer(), pcfParameters); set("processes", mapper.inquire()); } diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index 9db8fc3..40b1215 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -168,19 +168,14 @@ void QueueController::inquire() pcfParameters->set("ExcludeTemp", form().get("ExcludeTemp", "false").compare("true") == 0); Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); - pcfParameters->set("QAttrs", attrs); - - Poco::Net::NameValueCollection::ConstIterator itAttrs = form().find("QAttrs"); - if ( itAttrs == form().end() ) + formElementToJSONArray("QAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for QAttrs, try Attrs { - itAttrs = form().find("Attrs"); + formElementToJSONArray("Attrs", attrs); } - - for(; - itAttrs != form().end() && Poco::icompare(itAttrs->first, "Attrs") == 0; - ++itAttrs) + if ( attrs->size() > 0 ) { - attrs->add(itAttrs->second); + pcfParameters->set("QAttrs", attrs); } } diff --git a/MQWeb/src/QueueManagerController.cpp b/MQWeb/src/QueueManagerController.cpp index c88ab7f..9ce8341 100644 --- a/MQWeb/src/QueueManagerController.cpp +++ b/MQWeb/src/QueueManagerController.cpp @@ -39,8 +39,35 @@ QueueManagerController::~QueueManagerController() void QueueManagerController::inquire() { - QueueManagerMapper mapper(*commandServer(), new Poco::JSON::Object()); + Poco::JSON::Object::Ptr pcfParameters; + if ( data().has("filter") && data().isObject("filter") ) + { + pcfParameters = data().getObject("filter"); + } + else + { + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("QMgrAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for QMgrAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("QMgrAttrs", attrs); + } + + if ( form().has("CommandScope") ) + { + pcfParameters->set("CommandScope", form().get("CommandScope")); + } + } + + QueueManagerMapper mapper(*commandServer(), pcfParameters); Poco::JSON::Array::Ptr json = mapper.inquire(); if ( json->size() > 0 ) { diff --git a/MQWeb/src/QueueManagerStatusController.cpp b/MQWeb/src/QueueManagerStatusController.cpp index eda5634..13d0b58 100644 --- a/MQWeb/src/QueueManagerStatusController.cpp +++ b/MQWeb/src/QueueManagerStatusController.cpp @@ -46,7 +46,30 @@ void QueueManagerStatusController::inquire() return; } - QueueManagerStatusMapper mapper(*commandServer(), new Poco::JSON::Object()); + Poco::JSON::Object::Ptr pcfParameters; + + if ( data().has("filter") && data().isObject("filter") ) + { + pcfParameters = data().getObject("filter"); + } + else + { + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("QMStatusAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for QMStatusAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("QMStatusAttrs", attrs); + } + } + + QueueManagerStatusMapper mapper(*commandServer(), pcfParameters); Poco::JSON::Array::Ptr json = mapper.inquire(); if ( json->size() > 0 ) diff --git a/MQWeb/src/QueueStatusController.cpp b/MQWeb/src/QueueStatusController.cpp index d1727ad..331f3c7 100644 --- a/MQWeb/src/QueueStatusController.cpp +++ b/MQWeb/src/QueueStatusController.cpp @@ -39,32 +39,80 @@ QueueStatusController::~QueueStatusController() void QueueStatusController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a queuename and will result in inquiring - // only that queue - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("queueName", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - if ( form().has("queueName") ) + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a queuename. If this is passed, the + // query parameter QName or queueName is ignored. + if ( parameters.size() > 1 ) { - std::string nameField = form().get("queueName"); - if ( nameField.empty() ) nameField = "*"; - filter->set("queueName", nameField); + pcfParameters->set("QName", parameters[1]); + } + else + { + // Handle query parameters + std::string queueName; + if ( form().has("QName") ) + { + queueName = form().get("QName"); + } + else if ( form().has("QueueName") ) + { + queueName = form().get("QueueName"); + } + else if ( form().has("name") ) + { + queueName = form().get("name"); + } + + if ( queueName.empty() ) + { + queueName = "*"; + } + pcfParameters->set("QName", queueName); } - filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); - filter->set("excludeTemp", form().get("excludeTemp", "false").compare("true") == 0); - } - if ( form().has("statusType") ) filter->set("statusType", form().get("statusType")); - if ( form().has("openType") ) filter->set("openType", form().get("openType")); + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + pcfParameters->set("ExcludeTemp", form().get("ExcludeTemp", "false").compare("true") == 0); + + if ( form().has("CommandScope") ) + { + pcfParameters->set("CommandScope", form().get("CommandScope")); + } + if ( form().has("QSGDisposition") ) + { + pcfParameters->set("QSGDisposition", form().get("QSGDisposition")); + } + + if ( form().has("StatusType") ) pcfParameters->set("StatusType", form().get("StatusType")); + if ( form().has("OpenType") ) pcfParameters->set("OpenType", form().get("OpenType")); + + handleFilterForm(pcfParameters); + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("QStatusAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for QStatusAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("QStatusAttrs", attrs); + } + + } - QueueStatusMapper mapper(*commandServer(), filter); + QueueStatusMapper mapper(*commandServer(), pcfParameters); set("statuses", mapper.inquire()); } diff --git a/MQWeb/src/ServiceController.cpp b/MQWeb/src/ServiceController.cpp index f379e76..ec56382 100644 --- a/MQWeb/src/ServiceController.cpp +++ b/MQWeb/src/ServiceController.cpp @@ -40,24 +40,61 @@ ServiceController::~ServiceController() void ServiceController::inquire() { - Poco::JSON::Object::Ptr filter = new Poco::JSON::Object(); + Poco::JSON::Object::Ptr pcfParameters; - std::vector parameters = getParameters(); - // First parameter is queuemanager - // Second parameter can be a servicename and will result in inquiring - // only that serive. - if ( parameters.size() > 1 ) + if ( data().has("filter") && data().isObject("filter") ) { - filter->set("name", parameters[1]); + pcfParameters = data().getObject("filter"); } else { - std::string serviceNameField = form().get("serviceName", "*"); - filter->set("name", serviceNameField.empty() ? "*" : serviceNameField); - filter->set("excludeSystem", form().get("excludeSystem", "false").compare("true") == 0); + pcfParameters = new Poco::JSON::Object(); + set("filter", pcfParameters); + + std::vector parameters = getParameters(); + // First parameter is queuemanager + // Second parameter can be a servicename. If this is passed + // the query parameter ServiceName is ignored. + if ( parameters.size() > 1 ) + { + pcfParameters->set("ServiceName", parameters[1]); + } + else + { + // Handle query parameters + std::string serviceNameField; + if ( form().has("ServiceName") ) + { + serviceNameField = form().get("ServiceName"); + } + else if ( form().has("name") ) + { + serviceNameField = form().get("name"); + } + if ( serviceNameField.empty() ) + { + serviceNameField = "*"; + } + pcfParameters->set("ServiceName", serviceNameField); + } + + pcfParameters->set("ExcludeSystem", form().get("ExcludeSystem", "false").compare("true") == 0); + + Poco::JSON::Array::Ptr attrs = new Poco::JSON::Array(); + formElementToJSONArray("ServiceAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ServiceAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ServiceAttrs", attrs); + } + + handleFilterForm(pcfParameters); } - ServiceMapper mapper(*commandServer(), filter); + ServiceMapper mapper(*commandServer(), pcfParameters); set("services", mapper.inquire()); } From a7a382e8c4ae4493e6417b717e95ade5dc481b20 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 1 Oct 2014 22:07:11 +0200 Subject: [PATCH 098/143] Add more samples --- samples/pygmentize_samples.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index 382ca46..dfbc531 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -15,3 +15,7 @@ pygmentize -o $1/api/samples/channel_inq.pl.html ./channel_inq.pl pygmentize -o $1/api/samples/channel_inq.php.html ./channel_inq.php pygmentize -o $1/api/samples/chstatus_inq.pl.html ./chstatus_inq.pl pygmentize -o $1/api/samples/chstatus_inq.php.html ./chstatus_inq.php +pygmentize -o $1/api/samples/clusqmgr_inq.pl.html ./clusqmgr_inq.pl +pygmentize -o $1/api/samples/clusqmgr_inq.php.html ./clusqmgr_inq.php +pygmentize -o $1/api/samples/conn_inq.pl.html ./conn_inq.pl +pygmentize -o $1/api/samples/conn_inq.php.html ./conn_inq.php From db1f24be93a8a96077242c5863c5c057d5f35292 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 2 Oct 2014 09:23:11 +0200 Subject: [PATCH 099/143] Create new file --- samples/listener_inq.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 samples/listener_inq.php diff --git a/samples/listener_inq.php b/samples/listener_inq.php new file mode 100644 index 0000000..ac34fe0 --- /dev/null +++ b/samples/listener_inq.php @@ -0,0 +1,15 @@ + Date: Thu, 2 Oct 2014 09:27:08 +0200 Subject: [PATCH 100/143] Create new file --- samples/listener_inq.pl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 samples/listener_inq.pl diff --git a/samples/listener_inq.pl b/samples/listener_inq.pl new file mode 100644 index 0000000..cb61c3a --- /dev/null +++ b/samples/listener_inq.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'ListenerName' => '*', + 'ListenerAttrs' => [ + 'ListenerName', + 'TransportType' + ] +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/listener/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); From f7487190bb16c233f2622c279227699b2166e11e Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 2 Oct 2014 13:07:45 +0200 Subject: [PATCH 101/143] Create new file --- samples/service_inq.pl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 samples/service_inq.pl diff --git a/samples/service_inq.pl b/samples/service_inq.pl new file mode 100644 index 0000000..838f44c --- /dev/null +++ b/samples/service_inq.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'ServiceName' => '*', + 'ServiceAttrs' => [ 'ServiceName' ] +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/service/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); From bb9f5419c7094e653bf5025e3c00d5dd36f37181 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 2 Oct 2014 14:08:52 +0200 Subject: [PATCH 102/143] Handle StringList --- MQWeb/src/Dictionary.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/MQWeb/src/Dictionary.cpp b/MQWeb/src/Dictionary.cpp index ed61b42..28e50b6 100644 --- a/MQWeb/src/Dictionary.cpp +++ b/MQWeb/src/Dictionary.cpp @@ -153,9 +153,20 @@ void Dictionary::mapToJSON(const PCF& pcf, Poco::JSON::Object::Ptr& json, bool a } } } + else if ( pcf.isStringList(*it) ) + { + Poco::JSON::Array::Ptr jsonValues = new Poco::JSON::Array(); + field->set("value", jsonValues); + + std::vector strings = pcf.getParameterStringList(*it); + for(std::vector::iterator vit = strings.begin(); vit != strings.end(); ++vit) + { + jsonValues->add(*vit); + } + } else { - //TODO: + poco_assert_dbg(false); } } } From c09b2f1d7c1b445e0f6514248651f8e615ba2c95 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 2 Oct 2014 14:10:04 +0200 Subject: [PATCH 103/143] Create new file --- samples/namelist_inq.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 samples/namelist_inq.pl diff --git a/samples/namelist_inq.pl b/samples/namelist_inq.pl new file mode 100644 index 0000000..8389f37 --- /dev/null +++ b/samples/namelist_inq.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'NamelistName' => '*' +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/nl/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); From 9218c09eedc365accebd9d998d0e4cc36dbe0a22 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 2 Oct 2014 15:12:17 +0200 Subject: [PATCH 104/143] Create new file --- samples/process_inq.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 samples/process_inq.pl diff --git a/samples/process_inq.pl b/samples/process_inq.pl new file mode 100644 index 0000000..e3724be --- /dev/null +++ b/samples/process_inq.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'ProcessName' => '*' +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/process/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); From 5731795e4f1819c7bc9eaf576801f64afbce9314 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 2 Oct 2014 15:49:12 +0200 Subject: [PATCH 105/143] Create new file --- samples/qmstatus.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 samples/qmstatus.pl diff --git a/samples/qmstatus.pl b/samples/qmstatus.pl new file mode 100644 index 0000000..a9897fe --- /dev/null +++ b/samples/qmstatus.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( +); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/qmstatus/inquire/' . $qmgr; +$req->header( 'Content-Type' => 'application/json' ); +$req->content($json->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); From ba650a34192fe3135607c02ebedfc5e2ef04e1cf Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 2 Oct 2014 18:43:44 +0200 Subject: [PATCH 106/143] Reorganize samples --- poco.lua | 4 +-- samples/{ => perl}/authinfo_inq.pl | 0 samples/{ => perl}/authrec_inq.pl | 0 samples/{ => perl}/channel_inq.pl | 0 samples/{ => perl}/chstatus_inq.pl | 0 samples/{ => perl}/clusqmgr_inq.pl | 0 samples/{ => perl}/conn_inq.pl | 0 samples/{ => perl}/listener_inq.pl | 0 samples/{ => perl}/namelist_inq.pl | 0 samples/{ => perl}/process_inq.pl | 0 samples/{ => perl}/qmstatus.pl | 0 samples/{ => perl}/queue_inq.pl | 0 samples/{ => perl}/service_inq.pl | 0 samples/{ => php}/authinfo_inq.php | 0 samples/{ => php}/authrec_inq.php | 0 samples/{ => php}/channel_inq.php | 0 samples/{ => php}/chstatus_inq.php | 0 samples/{ => php}/clusqmgr_inq.php | 0 samples/{ => php}/conn_inq.php | 0 samples/{ => php}/guzzle.php | 0 samples/{ => php}/listener_inq.php | 0 samples/{ => php}/queue_inq.php | 0 samples/pygmentize_samples.sh | 39 +++++++++++++++++++----------- 23 files changed, 27 insertions(+), 16 deletions(-) rename samples/{ => perl}/authinfo_inq.pl (100%) rename samples/{ => perl}/authrec_inq.pl (100%) rename samples/{ => perl}/channel_inq.pl (100%) rename samples/{ => perl}/chstatus_inq.pl (100%) rename samples/{ => perl}/clusqmgr_inq.pl (100%) rename samples/{ => perl}/conn_inq.pl (100%) rename samples/{ => perl}/listener_inq.pl (100%) rename samples/{ => perl}/namelist_inq.pl (100%) rename samples/{ => perl}/process_inq.pl (100%) rename samples/{ => perl}/qmstatus.pl (100%) rename samples/{ => perl}/queue_inq.pl (100%) rename samples/{ => perl}/service_inq.pl (100%) rename samples/{ => php}/authinfo_inq.php (100%) rename samples/{ => php}/authrec_inq.php (100%) rename samples/{ => php}/channel_inq.php (100%) rename samples/{ => php}/chstatus_inq.php (100%) rename samples/{ => php}/clusqmgr_inq.php (100%) rename samples/{ => php}/conn_inq.php (100%) rename samples/{ => php}/guzzle.php (100%) rename samples/{ => php}/listener_inq.php (100%) rename samples/{ => php}/queue_inq.php (100%) diff --git a/poco.lua b/poco.lua index 543ab88..b438a57 100644 --- a/poco.lua +++ b/poco.lua @@ -12,8 +12,8 @@ poco_dir = "" poco_lib_dir = poco_dir .. "" -- A Linux example: ---poco_dir = "/home/bronx/Development/poco" -- where did you extract POCO? ---poco_lib_dir = poco_dir .. "/static/lib/Linux/i686" -- where are the libraries? +poco_dir = "/home/bronx/Development/poco" -- where did you extract POCO? +poco_lib_dir = poco_dir .. "/static/lib/Linux/i686" -- where are the libraries? -- A Windows example: --poco_dir = "c:\\development\\poco-1.5.2-release" diff --git a/samples/authinfo_inq.pl b/samples/perl/authinfo_inq.pl similarity index 100% rename from samples/authinfo_inq.pl rename to samples/perl/authinfo_inq.pl diff --git a/samples/authrec_inq.pl b/samples/perl/authrec_inq.pl similarity index 100% rename from samples/authrec_inq.pl rename to samples/perl/authrec_inq.pl diff --git a/samples/channel_inq.pl b/samples/perl/channel_inq.pl similarity index 100% rename from samples/channel_inq.pl rename to samples/perl/channel_inq.pl diff --git a/samples/chstatus_inq.pl b/samples/perl/chstatus_inq.pl similarity index 100% rename from samples/chstatus_inq.pl rename to samples/perl/chstatus_inq.pl diff --git a/samples/clusqmgr_inq.pl b/samples/perl/clusqmgr_inq.pl similarity index 100% rename from samples/clusqmgr_inq.pl rename to samples/perl/clusqmgr_inq.pl diff --git a/samples/conn_inq.pl b/samples/perl/conn_inq.pl similarity index 100% rename from samples/conn_inq.pl rename to samples/perl/conn_inq.pl diff --git a/samples/listener_inq.pl b/samples/perl/listener_inq.pl similarity index 100% rename from samples/listener_inq.pl rename to samples/perl/listener_inq.pl diff --git a/samples/namelist_inq.pl b/samples/perl/namelist_inq.pl similarity index 100% rename from samples/namelist_inq.pl rename to samples/perl/namelist_inq.pl diff --git a/samples/process_inq.pl b/samples/perl/process_inq.pl similarity index 100% rename from samples/process_inq.pl rename to samples/perl/process_inq.pl diff --git a/samples/qmstatus.pl b/samples/perl/qmstatus.pl similarity index 100% rename from samples/qmstatus.pl rename to samples/perl/qmstatus.pl diff --git a/samples/queue_inq.pl b/samples/perl/queue_inq.pl similarity index 100% rename from samples/queue_inq.pl rename to samples/perl/queue_inq.pl diff --git a/samples/service_inq.pl b/samples/perl/service_inq.pl similarity index 100% rename from samples/service_inq.pl rename to samples/perl/service_inq.pl diff --git a/samples/authinfo_inq.php b/samples/php/authinfo_inq.php similarity index 100% rename from samples/authinfo_inq.php rename to samples/php/authinfo_inq.php diff --git a/samples/authrec_inq.php b/samples/php/authrec_inq.php similarity index 100% rename from samples/authrec_inq.php rename to samples/php/authrec_inq.php diff --git a/samples/channel_inq.php b/samples/php/channel_inq.php similarity index 100% rename from samples/channel_inq.php rename to samples/php/channel_inq.php diff --git a/samples/chstatus_inq.php b/samples/php/chstatus_inq.php similarity index 100% rename from samples/chstatus_inq.php rename to samples/php/chstatus_inq.php diff --git a/samples/clusqmgr_inq.php b/samples/php/clusqmgr_inq.php similarity index 100% rename from samples/clusqmgr_inq.php rename to samples/php/clusqmgr_inq.php diff --git a/samples/conn_inq.php b/samples/php/conn_inq.php similarity index 100% rename from samples/conn_inq.php rename to samples/php/conn_inq.php diff --git a/samples/guzzle.php b/samples/php/guzzle.php similarity index 100% rename from samples/guzzle.php rename to samples/php/guzzle.php diff --git a/samples/listener_inq.php b/samples/php/listener_inq.php similarity index 100% rename from samples/listener_inq.php rename to samples/php/listener_inq.php diff --git a/samples/queue_inq.php b/samples/php/queue_inq.php similarity index 100% rename from samples/queue_inq.php rename to samples/php/queue_inq.php diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index dfbc531..da85635 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -5,17 +5,28 @@ if [ -z "$1" ] exit fi -pygmentize -o $1/api/samples/authinfo_inq.php.html ./authinfo_inq.php -pygmentize -o $1/api/samples/authinfo_inq.pl.html ./authinfo_inq.pl -pygmentize -o $1/api/samples/authrec_inq.php.html ./authrec_inq.php -pygmentize -o $1/api/samples/authrec_inq.pl.html ./authrec_inq.pl -pygmentize -o $1/api/samples/queue_inq.pl.html ./queue_inq.pl -pygmentize -o $1/api/samples/queue_inq.php.html ./queue_inq.php -pygmentize -o $1/api/samples/channel_inq.pl.html ./channel_inq.pl -pygmentize -o $1/api/samples/channel_inq.php.html ./channel_inq.php -pygmentize -o $1/api/samples/chstatus_inq.pl.html ./chstatus_inq.pl -pygmentize -o $1/api/samples/chstatus_inq.php.html ./chstatus_inq.php -pygmentize -o $1/api/samples/clusqmgr_inq.pl.html ./clusqmgr_inq.pl -pygmentize -o $1/api/samples/clusqmgr_inq.php.html ./clusqmgr_inq.php -pygmentize -o $1/api/samples/conn_inq.pl.html ./conn_inq.pl -pygmentize -o $1/api/samples/conn_inq.php.html ./conn_inq.php +pygmentize -o $1/api/samples/php/authinfo_inq.html ./php/authinfo_inq.php +pygmentize -o $1/api/samples/perl/authinfo_inq.html ./perl/authinfo_inq.pl +pygmentize -o $1/api/samples/php/authrec_inq.html ./php/authrec_inq.php +pygmentize -o $1/api/samples/perl/authrec_inq.html ./perl/authrec_inq.pl +pygmentize -o $1/api/samples/perl/queue_inq.html ./perl/queue_inq.pl +pygmentize -o $1/api/samples/php/queue_inq.html ./php/queue_inq.php +pygmentize -o $1/api/samples/perl/channel_inq.html ./perl/channel_inq.pl +pygmentize -o $1/api/samples/php/channel_inq.html ./php/channel_inq.php +pygmentize -o $1/api/samples/perl/chstatus_inq.html ./perl/chstatus_inq.pl +pygmentize -o $1/api/samples/php/chstatus_inq.html ./php/chstatus_inq.php +pygmentize -o $1/api/samples/perl/clusqmgr_inq.html ./perl/clusqmgr_inq.pl +pygmentize -o $1/api/samples/php/clusqmgr_inq.html ./php/clusqmgr_inq.php +pygmentize -o $1/api/samples/perl/conn_inq.html ./perl/conn_inq.pl +pygmentize -o $1/api/samples/php/conn_inq.html ./php/conn_inq.php +pygmentize -o $1/api/samples/perl/listener_inq.html ./perl/listener_inq.pl +pygmentize -o $1/api/samples/php/listener_inq.html ./php/listener_inq.php +pygmentize -o $1/api/samples/perl/namelist_inq.html ./perl/namelist_inq.pl +pygmentize -o $1/api/samples/php/namelist_inq.html ./php/namelist_inq.php +pygmentize -o $1/api/samples/perl/process_inq.html ./perl/process_inq.pl +pygmentize -o $1/api/samples/php/process_inq.html ./php/process_inq.php +pygmentize -o $1/api/samples/perl/service_inq.html ./perl/service_inq.pl +pygmentize -o $1/api/samples/php/service_inq.html ./php/service_inq.php +pygmentize -o $1/api/samples/perl/qmstatus.html ./perl/qmstatus_inq.pl +pygmentize -o $1/api/samples/php/qmstatus.html ./php/qmstatus_inq.php + From bb771b8b7c1679d99b77dd3b8dcc7290aef207f8 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Wed, 8 Oct 2014 13:55:08 +0200 Subject: [PATCH 107/143] Make the example more realistic ... --- samples/php/queue_inq.php | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/samples/php/queue_inq.php b/samples/php/queue_inq.php index fe5bca1..acd014a 100644 --- a/samples/php/queue_inq.php +++ b/samples/php/queue_inq.php @@ -1,15 +1,39 @@ error) ) { + echo "An MQ error occurred while inquiring queues.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->queues) && count($json->queues) > 0 ) { + foreach($json->queues as $queue) + { + echo $queue->QName->value; + if ( isset($queue->CurrentQDepth) ) { + echo ': ' . $queue->CurrentQDepth->value; + } + echo "\n"; + } + } + else + { + echo "No queues found\n"; + } + } + } From 47a1ae40e9cdc21b365cd39d715039a9b7eab61b Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Wed, 8 Oct 2014 15:11:33 +0200 Subject: [PATCH 108/143] Make the example more realistic ... --- samples/php/channel_inq.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/samples/php/channel_inq.php b/samples/php/channel_inq.php index b31016e..efe3621 100644 --- a/samples/php/channel_inq.php +++ b/samples/php/channel_inq.php @@ -1,15 +1,36 @@ error) ) { + echo "An MQ error occurred while inquiring channels.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->channels) && count($json->channels) > 0 ) { + foreach($json->channels as $channel) + { + echo $channel->ChannelName->value; + echo "\n"; + } + } + else + { + echo "No client channels found\n"; + } + } + } From 5edcc385ccf00c032b4af5798bb8bb61571eac8d Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Wed, 8 Oct 2014 15:12:56 +0200 Subject: [PATCH 109/143] Correct error message --- samples/php/channel_inq.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/php/channel_inq.php b/samples/php/channel_inq.php index efe3621..8245d02 100644 --- a/samples/php/channel_inq.php +++ b/samples/php/channel_inq.php @@ -12,7 +12,7 @@ if ( ($response = curl_exec($curl) ) === false ) { $err = curl_error($curl); - echo "An HTTP error occurred while getting queue information: $err\n"; + echo "An HTTP error occurred while inquiring channel information: $err\n"; } else { $json = json_decode($response); From 0e1cee35c5a188a6684f5dff5031ca8171c09ed3 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 8 Oct 2014 18:47:02 +0200 Subject: [PATCH 110/143] nodejs: inquire queues example --- samples/js/queue_inq.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 samples/js/queue_inq.js diff --git a/samples/js/queue_inq.js b/samples/js/queue_inq.js new file mode 100644 index 0000000..bd60ce2 --- /dev/null +++ b/samples/js/queue_inq.js @@ -0,0 +1,41 @@ +var http = require('http'); + +var options = { + hostname : '127.0.0.1', + port : 8081, + path : '/api/queue/inquire/PIGEON', + method : 'GET', + headers : { + } +}; + +var req = http.request(options, function(res) { + + var output = ''; + + res.setEncoding('utf8'); + + res.on('data', function (data) { + output += data; + }); + + res.on('end', function() { + var json = JSON.parse(output); + if ( json.error ) { + console.log("An MQException occurred: RC= " + json.error.reason.code + " - " + json.error.reason.desc); + } + else { + if ( json.queues ) { + for(q in json.queues) { + console.log(json.queues[q].QName.value); + } + } + } + }); +}); + +req.on('error', function(e) { + console.log('problem with request: ' + e.message); +}); + +req.end(); From 0e7be0261e55305d0ab303770f1309fe3641d901 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 10 Oct 2014 18:51:20 +0200 Subject: [PATCH 111/143] A first Ruby example --- samples/ruby/queue_inq.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 samples/ruby/queue_inq.rb diff --git a/samples/ruby/queue_inq.rb b/samples/ruby/queue_inq.rb new file mode 100644 index 0000000..05de043 --- /dev/null +++ b/samples/ruby/queue_inq.rb @@ -0,0 +1,27 @@ +require 'net/http' +require 'uri' +require 'json' + +uri = URI.parse('http://localhost:8081/api/queue/inquire/PIGEON') + +http = Net::HTTP.new(uri.host, uri.port) + +begin + response = http.request(Net::HTTP::Get.new(uri.request_uri)) +rescue Errno::ECONNREFUSED + puts "Can't connect to MQWeb. Is it running?" + abort +end + +if response.code == "200" + json = JSON.parse(response.body) + if json["error"] + puts "An MQException occurred: RC= #{json["error"]["reason"]["code"]} - #{json["error"]["reason"]["desc"]}" + else + json["queues"].each do |queue| + puts queue["QName"]["value"] + end + end +else + puts "A problem occurred with HTTP request: #{response.code}" +end From e206490d3f91a5bbe51fb9746dd7b084d09460df Mon Sep 17 00:00:00 2001 From: fbraem Date: Sat, 11 Oct 2014 19:14:26 +0200 Subject: [PATCH 112/143] Don't throw PCF exception for MQRCCF_CHL_STATUS_NOT_FOUND --- MQWeb/src/MQMapper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index f9a0a31..f91ed27 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -199,7 +199,8 @@ void MQMapper::execute(PCF::Vector& response) if ( (*it)->getCompletionCode() == MQCC_FAILED && (*it)->getReasonCode() > 3000 && (*it)->getReasonCode() < 4000 - && (*it)->getReasonCode() != MQRCCF_NONE_FOUND ) + && (*it)->getReasonCode() != MQRCCF_NONE_FOUND + && (*it)->getReasonCode() != MQRCCF_CHL_STATUS_NOT_FOUND ) { static Poco::SharedPtr dict = _dictionaryCache.getDictionary("Event"); std::string command = dict->getDisplayValue(MQIACF_COMMAND, (*it)->getCommand()); From 362c6fd3cddeb2b91ed502c4d840d87266935d88 Mon Sep 17 00:00:00 2001 From: fbraem Date: Sat, 11 Oct 2014 19:17:23 +0200 Subject: [PATCH 113/143] Make the sample more realistic --- samples/php/chstatus_inq.php | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/samples/php/chstatus_inq.php b/samples/php/chstatus_inq.php index 4502061..a9d8c49 100644 --- a/samples/php/chstatus_inq.php +++ b/samples/php/chstatus_inq.php @@ -5,11 +5,34 @@ * MQWeb runs on localhost and is listening on port 8081. */ $url = "http://localhost:8081/api/chstatus/inquire/PIGEON?ChannelType=Server-connection"; + $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - $response = curl_exec($curl); - $data = json_decode($response, true); - print_r($data); + + if ( ($response = curl_exec($curl)) === false ) { + $err = curl_error($curl); + echo "An HTTP error occurred while getting queue information: $err\n"; + } + else { + $json = json_decode($response); + if ( isset($json->error) ) { + echo "An MQ error occurred while inquiring queues.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->statuses) && count($json->statuses) > 0 ) { + foreach($json->statuses as $status) + { + echo $status->ChannelName->value; + echo " : "; + echo $status->ChannelStatus->display; + echo "\n"; + } + } + else + { + echo "No statuses found\n"; + } + } + } From b3e0098dbdcef697e6abed58f3c31cbf6abf55ef Mon Sep 17 00:00:00 2001 From: fbraem Date: Sat, 11 Oct 2014 20:12:38 +0200 Subject: [PATCH 114/143] Reworking the samples --- samples/php/authinfo_inq.php | 35 +++++++++++++++++++++++++++-------- samples/php/chstatus_inq.php | 5 ++--- samples/php/clusqmgr_inq.php | 33 ++++++++++++++++++++++++++++----- samples/php/listener_inq.php | 6 +++--- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/samples/php/authinfo_inq.php b/samples/php/authinfo_inq.php index d83855e..a1f4c18 100644 --- a/samples/php/authinfo_inq.php +++ b/samples/php/authinfo_inq.php @@ -1,16 +1,35 @@ error) ) { + echo "An MQ error occurred while inquiring authentication information objects.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->authinfos) && count($json->authinfos) > 0 ) { + foreach($json->authinfos as $authinfo) + { + echo $authinfo->AuthInfoName->value; + echo "\n"; + } + } + else + { + echo "No authentication information objects found\n"; + } + } + } diff --git a/samples/php/chstatus_inq.php b/samples/php/chstatus_inq.php index a9d8c49..cbcd066 100644 --- a/samples/php/chstatus_inq.php +++ b/samples/php/chstatus_inq.php @@ -1,5 +1,4 @@ error) ) { - echo "An MQ error occurred while inquiring queues.\n"; + echo "An MQ error occurred while inquiring channel statuses.\n"; echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; } else { diff --git a/samples/php/clusqmgr_inq.php b/samples/php/clusqmgr_inq.php index 1944a7f..ffa5eb4 100644 --- a/samples/php/clusqmgr_inq.php +++ b/samples/php/clusqmgr_inq.php @@ -5,11 +5,34 @@ * MQWeb runs on localhost and is listening on port 8081. */ $url = "http://localhost:8081/api/clusqmgr/inquire/PIGEON"; + $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - $response = curl_exec($curl); - $data = json_decode($response, true); - print_r($data); + + if ( ($response = curl_exec($curl)) === false ) { + $err = curl_error($curl); + echo "An HTTP error occurred while inquiring cluster queuemanagers: $err\n"; + } + else { + $json = json_decode($response); + if ( isset($json->error) ) { + echo "An MQ error occurred while inquiring cluster queuemanagers.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->clusqmgrs) && count($json->clusqmgrs) > 0 ) { + foreach($json->clusqmgrs as $clusqmgr) + { + echo $clusqmgr->ClusterName->value; + echo " : "; + echo $clusqmgr->QMgrName->value; + echo "\n"; + } + } + else + { + echo "No cluster queuemanagers found\n"; + } + } + } diff --git a/samples/php/listener_inq.php b/samples/php/listener_inq.php index ac34fe0..dfb9f8b 100644 --- a/samples/php/listener_inq.php +++ b/samples/php/listener_inq.php @@ -1,15 +1,15 @@ Date: Mon, 13 Oct 2014 19:32:20 +0200 Subject: [PATCH 115/143] Add more samples --- samples/perl/{qmstatus.pl => qmstatus_inq.pl} | 0 samples/php/namelist_inq.php | 38 +++++++++++++++++++ samples/php/process_inq.php | 35 +++++++++++++++++ samples/php/qmstatus_inq.php | 31 +++++++++++++++ samples/php/service_inq.php | 35 +++++++++++++++++ samples/pygmentize_samples.sh | 1 + 6 files changed, 140 insertions(+) rename samples/perl/{qmstatus.pl => qmstatus_inq.pl} (100%) create mode 100644 samples/php/namelist_inq.php create mode 100644 samples/php/process_inq.php create mode 100644 samples/php/qmstatus_inq.php create mode 100644 samples/php/service_inq.php diff --git a/samples/perl/qmstatus.pl b/samples/perl/qmstatus_inq.pl similarity index 100% rename from samples/perl/qmstatus.pl rename to samples/perl/qmstatus_inq.pl diff --git a/samples/php/namelist_inq.php b/samples/php/namelist_inq.php new file mode 100644 index 0000000..4535206 --- /dev/null +++ b/samples/php/namelist_inq.php @@ -0,0 +1,38 @@ +error) ) { + echo "An MQ error occurred while inquiring namelist.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->namelists) && count($json->namelists) > 0 ) { + foreach($json->namelists as $namelist) + { + echo $namelist->NamelistName->value; + echo ': '; + echo $namelist->NamelistDesc->value; + echo "\n"; + } + } + else + { + echo "No namelists found\n"; + } + } + } diff --git a/samples/php/process_inq.php b/samples/php/process_inq.php new file mode 100644 index 0000000..ff5d2dd --- /dev/null +++ b/samples/php/process_inq.php @@ -0,0 +1,35 @@ +error) ) { + echo "An MQ error occurred while inquiring processes.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->processes) && count($json->processes) > 0 ) { + foreach($json->processes as $process) + { + echo $process->ProcessName->value; + echo "\n"; + } + } + else + { + echo "No processes found\n"; + } + } + } diff --git a/samples/php/qmstatus_inq.php b/samples/php/qmstatus_inq.php new file mode 100644 index 0000000..9df9ab1 --- /dev/null +++ b/samples/php/qmstatus_inq.php @@ -0,0 +1,31 @@ +error) ) { + echo "An MQ error occurred while inquiring queuemanager status.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->status) ) { + echo "{$json->status->QMgrName->value} started on {$json->status->StartDate->value} {$json->status->StartTime->value}\n"; + } + else + { + echo "No status found\n"; + } + } + } diff --git a/samples/php/service_inq.php b/samples/php/service_inq.php new file mode 100644 index 0000000..0b6567f --- /dev/null +++ b/samples/php/service_inq.php @@ -0,0 +1,35 @@ +error) ) { + echo "An MQ error occurred while inquiring services.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->services) && count($json->services) > 0 ) { + foreach($json->services as $service) + { + echo $service->ServiceName->value; + echo "\n"; + } + } + else + { + echo "No services found\n"; + } + } + } diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index da85635..270e9c4 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -11,6 +11,7 @@ pygmentize -o $1/api/samples/php/authrec_inq.html ./php/authrec_inq.php pygmentize -o $1/api/samples/perl/authrec_inq.html ./perl/authrec_inq.pl pygmentize -o $1/api/samples/perl/queue_inq.html ./perl/queue_inq.pl pygmentize -o $1/api/samples/php/queue_inq.html ./php/queue_inq.php +pygmentize -o $1/api/samples/ruby/queue_inq.html ./ruby/queue_inq.rb pygmentize -o $1/api/samples/perl/channel_inq.html ./perl/channel_inq.pl pygmentize -o $1/api/samples/php/channel_inq.html ./php/channel_inq.php pygmentize -o $1/api/samples/perl/chstatus_inq.html ./perl/chstatus_inq.pl From cd15d0f74e8c64a6e20f43ee6a649578fcd36048 Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 15 Oct 2014 22:12:13 +0200 Subject: [PATCH 116/143] Keep working on samples ... --- samples/perl/lsstatus_inq.pl | 53 +++++++++++++++++++++++++++++++++++ samples/perl/qmgr_inq.pl | 50 +++++++++++++++++++++++++++++++++ samples/perl/queue_inq.pl | 46 +++++++++++++++++++++++++----- samples/perl/service_inq.pl | 10 +++++-- samples/php/authrec_inq.php | 45 +++++++++++++++++++++++++---- samples/php/conn_inq.php | 35 +++++++++++++++++++---- samples/php/lsstatus_inq.php | 14 +++++++++ samples/php/qmgr_inq.php | 40 ++++++++++++++++++++++++++ samples/php/qmstatus_inq.php | 25 ++++++++++++----- samples/pygmentize_samples.sh | 26 +++++++++-------- 10 files changed, 304 insertions(+), 40 deletions(-) create mode 100644 samples/perl/lsstatus_inq.pl create mode 100644 samples/perl/qmgr_inq.pl create mode 100644 samples/php/lsstatus_inq.php create mode 100644 samples/php/qmgr_inq.php diff --git a/samples/perl/lsstatus_inq.pl b/samples/perl/lsstatus_inq.pl new file mode 100644 index 0000000..303a287 --- /dev/null +++ b/samples/perl/lsstatus_inq.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; + +# This sample will show the status of all listeners + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") + unless defined($qmgr); + +my $json = JSON->new; + +# There's no need to set ListenerName to * because this is the default, +# but we do it here to show how to build the json content. +my %input = ( + 'ListenerName' => '*', +); +my $content = $json->encode(\%input); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/lsstatus/inquire/' . $qmgr; +$req->header( + 'Content-Type' => 'application/json', + 'Content-length' => length($content) +); +$req->content($content); + +my $res = $ua->request($req); +if ($res->is_success) { + my $mqweb = $json->decode($res->content()); + if ( exists($mqweb->{error}) ) { + print "An MQ error occurred while inquiring listener status.\n", + 'Reason Code: ', + $mqweb->{error}->{reason}->{code}, + ' - ', + $mqweb->{error}->{reason}->{desc}, + "\n"; + } + else { + foreach my $status(@{$mqweb->{statuses}}) { + print $status->{ListenerName}->{value}; + print ' : ', $status->{Status}->{display}; + print "\n"; + } + } +} +else { + die $res->status_line; +} + diff --git a/samples/perl/qmgr_inq.pl b/samples/perl/qmgr_inq.pl new file mode 100644 index 0000000..af1bfa7 --- /dev/null +++ b/samples/perl/qmgr_inq.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +use strict; +use warnings; +use JSON; +use LWP::UserAgent; +use HTTP::Request::Common; +use feature qw(say); + +# This sample will show the description of the queuemanager + +my $qmgr = shift; +die("Please pass me the name of a queuemanager as argument") + unless defined($qmgr); + +my $json = JSON->new; + +my %input = ( + 'QMgrAttrs' => [ + 'QMgrDesc' + ], +); +my $content = $json->encode(\%input); + +my $ua = LWP::UserAgent->new; +my $req = POST 'http://localhost:8081/api/qmgr/inquire/' . $qmgr; +$req->header( + 'Content-Type' => 'application/json', + 'Content-length' => length($content) +); +$req->content($content); + +my $res = $ua->request($req); +if ($res->is_success) { + my $mqweb = $json->decode($res->content()); + if ( exists($mqweb->{error}) ) { + say 'An MQ error occurred while inquiring queuemanager.'; + say 'Reason Code: ', + $mqweb->{error}->{reason}->{code}, + ' - ', + $mqweb->{error}->{reason}->{desc}; + } + else { + say $mqweb->{qmgr}->{QMgrName}->{value}, + ' : ', + $mqweb->{qmgr}->{QMgrDesc}->{value}; + } +} +else { + die $res->status_line; +} diff --git a/samples/perl/queue_inq.pl b/samples/perl/queue_inq.pl index 170bf27..fed27b6 100644 --- a/samples/perl/queue_inq.pl +++ b/samples/perl/queue_inq.pl @@ -5,20 +5,52 @@ use LWP::UserAgent; use HTTP::Request::Common; +# This sample will show all SYSTEM queues from the given queuemanager and +# prints the current queue depth if this property exists for the queue. + my $qmgr = shift; -die("Please pass me the name of a queuemanager as argument") unless defined($qmgr); +die("Please pass me the name of a queuemanager as argument") + unless defined($qmgr); my $json = JSON->new; my %input = ( - 'QName' => 'T*', + 'QName' => 'SYSTEM*', + 'QAttrs' => [ + 'CurrentQDepth' + # No need to add QName, it is always returned + ] ); +my $content = $json->encode(\%input); my $ua = LWP::UserAgent->new; -my $req = POST 'http://localhost:8081/api/queue/inquire/' . $qmgr; -$req->header( 'Content-Type' => 'application/json' ); -$req->content($json->encode(\%input)); +my $req = POST 'http://localhost:8081/api/queue/inquire/' . $qmgr; +$req->header( + 'Content-Type' => 'application/json', + 'Content-length' => length($content) +); +$req->content($content); my $res = $ua->request($req); - -print $json->pretty->encode($json->decode($res->content())); +if ($res->is_success) { + my $mqweb = $json->decode($res->content()); + if ( exists($mqweb->{error}) ) { + print "An MQ error occurred while inquiring queues.\n", + 'Reason Code: ', + $mqweb->{error}->{reason}->{code}, + ' - ', + $mqweb->{error}->{reason}->{desc}, + "\n"; + } + else { + foreach my $queue(@{$mqweb->{queues}}) { + print $queue->{QName}->{value}; + print ' : ', $queue->{CurrentQDepth}->{value} + if ( exists($queue->{CurrentQDepth}) ); + print "\n"; + } + } +} +else { + die $res->status_line; +} diff --git a/samples/perl/service_inq.pl b/samples/perl/service_inq.pl index 838f44c..a6ea8cb 100644 --- a/samples/perl/service_inq.pl +++ b/samples/perl/service_inq.pl @@ -14,11 +14,15 @@ 'ServiceName' => '*', 'ServiceAttrs' => [ 'ServiceName' ] ); +my $content = $json->encode(\%input); my $ua = LWP::UserAgent->new; -my $req = POST 'http://localhost:8081/api/service/inquire/' . $qmgr; -$req->header( 'Content-Type' => 'application/json' ); -$req->content($json->encode(\%input)); +my $req = POST 'http://localhost:8081/api/service/inquire/' . $qmgr; +$req->header( + 'Content-Type' => 'application/json', + 'Content-length' => length($content) +); +$req->content($content); my $res = $ua->request($req); diff --git a/samples/php/authrec_inq.php b/samples/php/authrec_inq.php index 43c0856..64a1d74 100644 --- a/samples/php/authrec_inq.php +++ b/samples/php/authrec_inq.php @@ -1,16 +1,49 @@ error) ) { + echo "An MQ error occurred while inquiring authority records.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->authrecs) && count($json->authrecs) > 0 ) { + foreach($json->authrecs as $authrec) + { + echo $authrec->ProfileName->value; + echo '('; + echo $authrec->ObjectType->display; + echo ')'; + echo ' - '; + echo $authrec->EntityName->value; + echo "\n"; + + $authorizations = array(); + foreach($authrec->AuthorizationList->value as $authorization) + { + $authorizations[] = $authorization->display; + } + echo " "; + echo join(', ', $authorizations); + echo "\n"; + } + } + else + { + echo "No authority records found\n"; + } + } + } diff --git a/samples/php/conn_inq.php b/samples/php/conn_inq.php index 88b67db..619fbe7 100644 --- a/samples/php/conn_inq.php +++ b/samples/php/conn_inq.php @@ -1,15 +1,38 @@ error) ) { + echo "An MQ error occurred while inquiring connections.\n"; + echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + } + else { + if ( isset($json->connections) && count($json->connections) > 0 ) { + foreach($json->connections as $connection) + { + echo $connection->ApplTag->value; + echo ' ('; + echo $connection->ApplType->display; + echo ')'; + echo "\n"; + } + } + else + { + echo "No connections found\n"; + } + } + } diff --git a/samples/php/lsstatus_inq.php b/samples/php/lsstatus_inq.php new file mode 100644 index 0000000..35585f4 --- /dev/null +++ b/samples/php/lsstatus_inq.php @@ -0,0 +1,14 @@ +error) ) { + echo 'An MQ error occurred while inquiring queuemanager status.' + . PHP_EOL; + echo 'Reason Code: ' + . $json->error->reason->code + . ' - ' + . $json->error->reason->desc + . PHP_EOL; + } + else { + if ( isset($json->qmgr) ) { + echo $json->qmgr->QMgrName->value + . ' : ' + . $json->qmgr->QMgrDesc->value + . PHP_EOL; + } + else { + echo 'No qmgr found' . PHP_EOL; + } + } + } diff --git a/samples/php/qmstatus_inq.php b/samples/php/qmstatus_inq.php index 9df9ab1..8aae7e0 100644 --- a/samples/php/qmstatus_inq.php +++ b/samples/php/qmstatus_inq.php @@ -11,21 +11,32 @@ if ( ($response = curl_exec($curl)) === false ) { $err = curl_error($curl); - echo "An HTTP error occurred while inquiring queuemanager status: $err\n"; + echo 'An HTTP error occurred while inquiring queuemanager status: ' + . $err + . PHP_EOL; } else { $json = json_decode($response); if ( isset($json->error) ) { - echo "An MQ error occurred while inquiring queuemanager status.\n"; - echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n"; + echo 'An MQ error occurred while inquiring queuemanager status.' + . PHP_EOL; + echo 'Reason Code: ' + . $json->error->reason->code + . ' - ' + . $json->error->reason->desc + . PHP_EOL; } else { if ( isset($json->status) ) { - echo "{$json->status->QMgrName->value} started on {$json->status->StartDate->value} {$json->status->StartTime->value}\n"; + echo $json->status->QMgrName->value + . ' started on ' + . $json->status->StartDate->value + . ' ' + . $json->status->StartTime->value + . PHP_EOL; } - else - { - echo "No status found\n"; + else { + echo 'No status found' . PHP_EOL; } } } diff --git a/samples/pygmentize_samples.sh b/samples/pygmentize_samples.sh index 270e9c4..5250c2b 100755 --- a/samples/pygmentize_samples.sh +++ b/samples/pygmentize_samples.sh @@ -9,25 +9,29 @@ pygmentize -o $1/api/samples/php/authinfo_inq.html ./php/authinfo_inq.php pygmentize -o $1/api/samples/perl/authinfo_inq.html ./perl/authinfo_inq.pl pygmentize -o $1/api/samples/php/authrec_inq.html ./php/authrec_inq.php pygmentize -o $1/api/samples/perl/authrec_inq.html ./perl/authrec_inq.pl -pygmentize -o $1/api/samples/perl/queue_inq.html ./perl/queue_inq.pl pygmentize -o $1/api/samples/php/queue_inq.html ./php/queue_inq.php +pygmentize -o $1/api/samples/perl/queue_inq.html ./perl/queue_inq.pl pygmentize -o $1/api/samples/ruby/queue_inq.html ./ruby/queue_inq.rb -pygmentize -o $1/api/samples/perl/channel_inq.html ./perl/channel_inq.pl pygmentize -o $1/api/samples/php/channel_inq.html ./php/channel_inq.php -pygmentize -o $1/api/samples/perl/chstatus_inq.html ./perl/chstatus_inq.pl +pygmentize -o $1/api/samples/perl/channel_inq.html ./perl/channel_inq.pl pygmentize -o $1/api/samples/php/chstatus_inq.html ./php/chstatus_inq.php -pygmentize -o $1/api/samples/perl/clusqmgr_inq.html ./perl/clusqmgr_inq.pl +pygmentize -o $1/api/samples/perl/chstatus_inq.html ./perl/chstatus_inq.pl pygmentize -o $1/api/samples/php/clusqmgr_inq.html ./php/clusqmgr_inq.php -pygmentize -o $1/api/samples/perl/conn_inq.html ./perl/conn_inq.pl +pygmentize -o $1/api/samples/perl/clusqmgr_inq.html ./perl/clusqmgr_inq.pl pygmentize -o $1/api/samples/php/conn_inq.html ./php/conn_inq.php -pygmentize -o $1/api/samples/perl/listener_inq.html ./perl/listener_inq.pl +pygmentize -o $1/api/samples/perl/conn_inq.html ./perl/conn_inq.pl pygmentize -o $1/api/samples/php/listener_inq.html ./php/listener_inq.php -pygmentize -o $1/api/samples/perl/namelist_inq.html ./perl/namelist_inq.pl +pygmentize -o $1/api/samples/perl/listener_inq.html ./perl/listener_inq.pl +pygmentize -o $1/api/samples/php/lsstatus_inq.html ./php/lsstatus_inq.php +pygmentize -o $1/api/samples/perl/lsstatus_inq.html ./perl/lsstatus_inq.pl pygmentize -o $1/api/samples/php/namelist_inq.html ./php/namelist_inq.php -pygmentize -o $1/api/samples/perl/process_inq.html ./perl/process_inq.pl +pygmentize -o $1/api/samples/perl/namelist_inq.html ./perl/namelist_inq.pl pygmentize -o $1/api/samples/php/process_inq.html ./php/process_inq.php -pygmentize -o $1/api/samples/perl/service_inq.html ./perl/service_inq.pl +pygmentize -o $1/api/samples/perl/process_inq.html ./perl/process_inq.pl pygmentize -o $1/api/samples/php/service_inq.html ./php/service_inq.php -pygmentize -o $1/api/samples/perl/qmstatus.html ./perl/qmstatus_inq.pl -pygmentize -o $1/api/samples/php/qmstatus.html ./php/qmstatus_inq.php +pygmentize -o $1/api/samples/perl/service_inq.html ./perl/service_inq.pl +pygmentize -o $1/api/samples/php/qmgr_inq.html ./php/qmgr_inq.php +pygmentize -o $1/api/samples/perl/qmgr_inq.html ./perl/qmgr_inq.pl +pygmentize -o $1/api/samples/php/qmstatus_inq.html ./php/qmstatus_inq.php +pygmentize -o $1/api/samples/perl/qmstatus_inq.html ./perl/qmstatus_inq.pl From 87fc60b8a1d3fa3308d72a80913cd577df9e421b Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Thu, 16 Oct 2014 14:17:53 +0200 Subject: [PATCH 117/143] Update queue_inq.pl --- samples/perl/queue_inq.pl | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/samples/perl/queue_inq.pl b/samples/perl/queue_inq.pl index fed27b6..e491135 100644 --- a/samples/perl/queue_inq.pl +++ b/samples/perl/queue_inq.pl @@ -1,6 +1,8 @@ #!/usr/bin/perl use strict; use warnings; +use feature qw(say); + use JSON; use LWP::UserAgent; use HTTP::Request::Common; @@ -32,25 +34,21 @@ $req->content($content); my $res = $ua->request($req); -if ($res->is_success) { - my $mqweb = $json->decode($res->content()); - if ( exists($mqweb->{error}) ) { - print "An MQ error occurred while inquiring queues.\n", - 'Reason Code: ', - $mqweb->{error}->{reason}->{code}, - ' - ', - $mqweb->{error}->{reason}->{desc}, - "\n"; - } - else { - foreach my $queue(@{$mqweb->{queues}}) { - print $queue->{QName}->{value}; - print ' : ', $queue->{CurrentQDepth}->{value} - if ( exists($queue->{CurrentQDepth}) ); - print "\n"; - } - } +die $res->status_line unless $res->is_success; + +my $mqweb = $json->decode($res->content()); +if ( exists($mqweb->{error}) ) { + say 'An MQ error occurred while inquiring queues.'; + say 'Reason Code: ' + , $mqweb->{error}->{reason}->{code} + , ' - ' + , $mqweb->{error}->{reason}->{desc}; } else { - die $res->status_line; + foreach my $queue(@{$mqweb->{queues}}) { + my $output = $queue->{QName}->{value}; + $output .= ' : ' . $queue->{CurrentQDepth}->{value} + if ( exists($queue->{CurrentQDepth}) ); + say $output; + } } From bdec0ea97f0b7a62a6d93c32d38fc648b0a1912d Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 16 Oct 2014 22:06:59 +0200 Subject: [PATCH 118/143] Don't fail anymore when there is no mq.web.templates / mq.web.static configuration --- MQWeb/src/Application.cpp | 104 ++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 56 deletions(-) diff --git a/MQWeb/src/Application.cpp b/MQWeb/src/Application.cpp index d9bc730..4243a59 100644 --- a/MQWeb/src/Application.cpp +++ b/MQWeb/src/Application.cpp @@ -142,65 +142,57 @@ int MQWebApplication::main(const std::vector& args) _cache.setLogger(logger); - // Check the template path configuration (mq.web.templates) - Poco::Path templatePath; - std::string templatesValue; - try - { - templatesValue = config().getString("mq.web.templates"); - templatesValue = config().expand(templatesValue); - templatePath.assign(templatesValue); - templatePath.makeDirectory(); - } - catch(Poco::NotFoundException&) - { - templatePath.assign(config().getString("application.dir")); - templatePath.pushDirectory("templates"); - poco_warning_f1(logger, "No mq.web.templates found in the configuration file. Trying to use %s", templatePath.toString()); - } - catch(Poco::PathSyntaxException&) - { - poco_fatal_f1(logger, "Invalid path specified for mq.web.templates: %s", templatesValue); - return Application::EXIT_CONFIG; + if ( config().has("mq.web.templates") ) + { + Poco::Path templatePath; + std::string templatesValue; + try + { + templatesValue = config().getString("mq.web.templates"); + templatesValue = config().expand(templatesValue); + templatePath.assign(templatesValue); + templatePath.makeDirectory(); + } + catch(Poco::PathSyntaxException&) + { + poco_fatal_f1(logger, "Invalid path specified for mq.web.templates: %s", templatesValue); + return Application::EXIT_CONFIG; + } + + Poco::File file(templatePath); + if ( !file.exists() ) + { + poco_fatal_f1(logger, "Template path %s doesn't exist! Check the configuration file.", templatePath.toString()); + return Application::EXIT_CONFIG; + } + + _cache.addPath(templatePath); } - Poco::File file(templatePath); - if ( !file.exists() ) - { - poco_fatal_f1(logger, "Template path %s doesn't exist! Check the configuration file.", templatePath.toString()); - return Application::EXIT_CONFIG; - } - - _cache.addPath(templatePath); - // Check the static path configuration (mq.web.static) - Poco::Path staticPath; - std::string staticValue; - try - { - staticValue = config().getString("mq.web.static"); - staticValue = config().expand(staticValue); - staticPath.assign(staticValue); - staticPath.makeDirectory(); - } - catch(Poco::NotFoundException&) - { - staticPath.assign(config().getString("application.dir")); - staticPath.pushDirectory("static"); - config().setString("mq.web.static", staticPath.toString()); - poco_warning_f1(logger, "No mq.web.static found in the configuration file. Trying to use %s", staticPath.toString()); - } - catch(Poco::PathSyntaxException&) - { - poco_fatal_f1(logger, "Invalid path specified for mq.web.static: %s", staticValue); - return Application::EXIT_CONFIG; - } - - file = Poco::File(staticPath); - if ( !file.exists() ) - { - poco_fatal_f1(logger, "Path for static files %s doesn't exist! Check the configuration file.", staticPath.toString()); - return Application::EXIT_CONFIG; + if ( config().has("mq.web.static") ) + { + Poco::Path staticPath; + std::string staticValue; + try + { + staticValue = config().getString("mq.web.static"); + staticValue = config().expand(staticValue); + staticPath.assign(staticValue); + staticPath.makeDirectory(); + } + catch(Poco::PathSyntaxException&) + { + poco_fatal_f1(logger, "Invalid path specified for mq.web.static: %s", staticValue); + return Application::EXIT_CONFIG; + } + + Poco::File file = Poco::File(staticPath); + if ( !file.exists() ) + { + poco_fatal_f1(logger, "Path for static files %s doesn't exist! Check the configuration file.", staticPath.toString()); + return Application::EXIT_CONFIG; + } } unsigned short port = (unsigned short) config().getInt("mq.web.port", 8081); From 3679459629f39aa98dee01b822a1ec542f3ac9dd Mon Sep 17 00:00:00 2001 From: fbraem Date: Sat, 18 Oct 2014 22:39:01 +0200 Subject: [PATCH 119/143] Working on connection pooling ... --- MQ/include/MQ/QueueManager.h | 17 +++- MQ/include/MQ/QueueManagerPool.h | 51 ++++++++++++ MQ/src/QueueManager.cpp | 56 +++++++++---- MQ/src/QueueManagerPool.cpp | 37 +++++++++ MQWeb/include/MQ/Web/QueueManagerPoolCache.h | 77 +++++++++++++++++ MQWeb/src/QueueManagerPoolCache.cpp | 87 ++++++++++++++++++++ 6 files changed, 304 insertions(+), 21 deletions(-) create mode 100644 MQ/include/MQ/QueueManagerPool.h create mode 100644 MQ/src/QueueManagerPool.cpp create mode 100644 MQWeb/include/MQ/Web/QueueManagerPoolCache.h create mode 100644 MQWeb/src/QueueManagerPoolCache.cpp diff --git a/MQ/include/MQ/QueueManager.h b/MQ/include/MQ/QueueManager.h index d484180..02b8ea2 100644 --- a/MQ/include/MQ/QueueManager.h +++ b/MQ/include/MQ/QueueManager.h @@ -29,7 +29,7 @@ #include "Poco/SharedPtr.h" #include "Poco/DateTime.h" -#include "Poco/Util/ConfigurationView.h" +#include "Poco/Dynamic/Struct.h" namespace MQ { @@ -39,7 +39,6 @@ class QueueManager public: typedef Poco::SharedPtr Ptr; - QueueManager(const std::string& name = ""); /// Constructor. @@ -53,7 +52,7 @@ class QueueManager /// Connects to the queuemanager. Only use this method when the Websphere /// MQ system is loaded in client mode. Can throw an MQException. - void connect(const std::string& channel, const std::string& server, const Poco::Util::AbstractConfiguration& ssl); + void connect(const std::string& channel, const std::string& server, const Poco::Dynamic::Struct& ssl); /// Connects to the queuemanager using a channel that is protected with SSL. /// The configuration for SSL is based on the following properties: keyrepos (required), /// cipherspec, fips, suiteb and certificate_validation_policy (only when @@ -61,6 +60,13 @@ class QueueManager /// Only use this method when MQ system is loaded in client mode. Can /// throw an MQException. + void connect(const Poco::Dynamic::Struct& connectionInformation); + /// Connect using the information stored in the Poco::Dynamic::Struct object + /// Can throw an MQException + + bool connected() const; + /// Returns true when the queuemanager is connected. + void disconnect(); /// Disconnects from the queuemanager. Can throw an MQException. @@ -115,6 +121,11 @@ inline std::string QueueManager::commandQueue() const return _commandQueue; } +inline bool QueueManager::connected() const +{ + return _handle != 0L; +} + inline bool QueueManager::zos() const { return _applicationType == MQPL_ZOS; diff --git a/MQ/include/MQ/QueueManagerPool.h b/MQ/include/MQ/QueueManagerPool.h new file mode 100644 index 0000000..8eb5d91 --- /dev/null +++ b/MQ/include/MQ/QueueManagerPool.h @@ -0,0 +1,51 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQ_QueueManagerPool_h +#define _MQ_QueueManagerPool_h + +#include "Poco/ObjectPool.h" + +#include "MQ/QueueManager.h" + + +namespace MQ { + + +class QueueManagerPool + /// This class implements a Queuemanager pool +{ +public: + typedef Poco::PoolableObjectFactory QueueManagerFactory; + + QueueManagerPool(const QueueManagerFactory& factory, std::size_t capacity, std::size_t peakCapacity); + /// Constructor. + + virtual ~QueueManagerPool(); + /// Destructor. + +private: + + Poco::ObjectPool _pool; +}; + +} // Namespace MQ + +#endif // _MQ_QueueManagerPool_h diff --git a/MQ/src/QueueManager.cpp b/MQ/src/QueueManager.cpp index afaded8..502b9c7 100644 --- a/MQ/src/QueueManager.cpp +++ b/MQ/src/QueueManager.cpp @@ -70,7 +70,7 @@ void QueueManager::connect(const std::string& channel, const std::string& server { MQCNO cno = { MQCNO_DEFAULT }; cno.Version = MQCNO_VERSION_2; - cno.Options = MQCNO_HANDLE_SHARE_NONE; + cno.Options = MQCNO_HANDLE_SHARE_BLOCK; MQCD cd = { MQCD_CLIENT_CONN_DEFAULT }; strncpy(cd.ChannelName, channel.c_str(), MQ_CHANNEL_NAME_LENGTH); @@ -85,7 +85,25 @@ void QueueManager::connect(const std::string& channel, const std::string& server } -void QueueManager::connect(const std::string& channel, const std::string& server, const Poco::Util::AbstractConfiguration& ssl) +void QueueManager::connect(const Poco::Dynamic::Struct& connectionInformation) +{ + Poco::Dynamic::Var ssl = connectionInformation["ssl"]; + if ( ssl.isEmpty() ) + { + connect(connectionInformation["channel"], connectionInformation["connection"]); + } + else + { + if ( ssl.isStruct() ) + { + connect(connectionInformation["channel"], + connectionInformation["connection"], + ssl.extract >()); + } + } +} + +void QueueManager::connect(const std::string& channel, const std::string& server, const Poco::Dynamic::Struct& ssl) { MQCNO cno = { MQCNO_DEFAULT }; @@ -94,15 +112,16 @@ void QueueManager::connect(const std::string& channel, const std::string& server connection pointer and SSL configuration options are used */ cno.Version = MQCNO_VERSION_4; - cno.Options = MQCNO_HANDLE_SHARE_NONE; + cno.Options = MQCNO_HANDLE_SHARE_BLOCK; MQCD cd = { MQCD_CLIENT_CONN_DEFAULT }; strncpy(cd.ChannelName, channel.c_str(), MQ_CHANNEL_NAME_LENGTH); strncpy(cd.ConnectionName, server.c_str(), MQ_CONN_NAME_LENGTH); - - if ( ssl.has("cipherspec") ) + + Poco::Dynamic::Var cipherspec = ssl["cipherspec"]; + if ( !cipherspec.isEmpty() ) { - strncpy(cd.SSLCipherSpec, ssl.getString("cipherspec").c_str(), MQ_SSL_CIPHER_SPEC_LENGTH); + strncpy(cd.SSLCipherSpec, cipherspec.toString().c_str(), MQ_SSL_CIPHER_SPEC_LENGTH); cd.Version = MQCD_VERSION_7; // SSL requires MQCD version 7 or later } cd.TransportType = MQXPT_TCP; @@ -111,15 +130,18 @@ void QueueManager::connect(const std::string& channel, const std::string& server MQSCO sco = { MQSCO_DEFAULT }; MQAIR authInfoRec = { MQAIR_DEFAULT }; - strncpy(sco.KeyRepository, ssl.getString("keyrepos").c_str(), MQ_SSL_KEY_REPOSITORY_LENGTH); + Poco::Dynamic::Var keyrepos = ssl["keyrepos"]; + strncpy(sco.KeyRepository, keyrepos.toString().c_str(), MQ_SSL_KEY_REPOSITORY_LENGTH); - if ( ssl.getBool("fips", false) ) + Poco::Dynamic::Var fips = ssl["fips"]; + if ( !fips.isEmpty() && fips.convert() ) { sco.FipsRequired = MQSSL_FIPS_YES; sco.Version = MQSCO_VERSION_2; // A version 2 MQSCO supports FipsRequired } - if ( ssl.has("suiteb") ) + Poco::Dynamic::Var suiteb = ssl["suiteb"]; + if ( ! suiteb.isEmpty() ) { static std::map suiteBTable; if ( suiteBTable.size() == 0 ) @@ -131,8 +153,7 @@ void QueueManager::connect(const std::string& channel, const std::string& server sco.Version = MQSCO_VERSION_3; /* A version 3 MQSCO supports Suite B encryption policy */ - std::string suiteb = ssl.getString("suiteb"); - Poco::StringTokenizer tokenizer(suiteb, ",", Poco::StringTokenizer::TOK_TRIM); + Poco::StringTokenizer tokenizer(suiteb.toString(), ",", Poco::StringTokenizer::TOK_TRIM); int n = 0; for(Poco::StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end() && n < 4; ++it, ++n) { @@ -149,7 +170,8 @@ void QueueManager::connect(const std::string& channel, const std::string& server } #ifdef MQSCO_VERSION_4 - if ( ssl.has("certificate_validation_policy") ) + Poco::Dynamic::Var certValPolicy = ssl["certificate_validation_policy"]; + if ( !certValPolicy.isEmpty() ) { static std::map certValPolicyTable; if ( certValPolicyTable.size() == 0 ) @@ -160,8 +182,7 @@ void QueueManager::connect(const std::string& channel, const std::string& server sco.Version = MQSCO_VERSION_4; /* A version 4 MQSCO supports certificate validation policy */ - std::string certValPolicy = ssl.getString("certificate_validation_policy"); - std::map::iterator certValPolicyIterator = certValPolicyTable.find(certValPolicy); + std::map::iterator certValPolicyIterator = certValPolicyTable.find(certValPolicy.toString()); if ( certValPolicyIterator == certValPolicyTable.end() ) { throw Poco::NotFoundException(Poco::format("Unknown Certification Validation Policy: %s", certValPolicy)); @@ -172,15 +193,14 @@ void QueueManager::connect(const std::string& channel, const std::string& server } } #endif - if ( ssl.has("ocsp_url") ) + Poco::Dynamic::Var ocsp = ssl["ocsp_url"]; + if ( !ocsp.isEmpty() ) { - std::string ocsp = ssl.getString("ocsp_url"); - /* OCSP requires MQAIR version 2 or later */ authInfoRec.Version = MQAIR_VERSION_2; authInfoRec.AuthInfoType = MQAIT_OCSP; - strncpy(authInfoRec.OCSPResponderURL, ocsp.c_str(), MQ_AUTH_INFO_OCSP_URL_LENGTH); + strncpy(authInfoRec.OCSPResponderURL, ocsp.toString().c_str(), MQ_AUTH_INFO_OCSP_URL_LENGTH); /* The MQSCO must point to the MQAIR */ sco.AuthInfoRecCount = 1; diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp new file mode 100644 index 0000000..ea685d7 --- /dev/null +++ b/MQ/src/QueueManagerPool.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ + +#include "MQ/QueueManagerPool.h" + +namespace MQ +{ + +QueueManagerPool::QueueManagerPool(const QueueManagerFactory& factory, std::size_t capacity, std::size_t peakCapacity) +: _pool(factory, capacity, peakCapacity) +{ +} + + +QueueManagerPool::~QueueManagerPool() +{ +} + +} // Namespace MQ diff --git a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h new file mode 100644 index 0000000..db9fc59 --- /dev/null +++ b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h @@ -0,0 +1,77 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#ifndef _MQ_QueueManagerPoolCache_h +#define _MQ_QueueManagerPoolCache_h + +#include "Poco/Dynamic/Struct.h" +#include "Poco/ExpireCache.h" +#include "MQ/QueueManagerPool.h" + + +namespace MQ { +namespace Web { + +class QueueManagerFactory : public QueueManagerPool::QueueManagerFactory +{ +public: + QueueManagerFactory(const std::string& qmgrName); + + QueueManagerFactory(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation); + + QueueManagerFactory(const QueueManagerFactory& factory); + + virtual ~QueueManagerFactory(); + + QueueManager::Ptr createObject(); + + void activateObject(QueueManager::Ptr qmgr); + +private: + + std::string _qmgrName; + + Poco::Dynamic::Struct _connectionInformation; +}; + +class QueueManagerPoolCache + /// This class implements a cache for queuemanager pools +{ +public: + + QueueManagerPoolCache(); + /// Constructor. + + virtual ~QueueManagerPoolCache(); + /// Destructor. + + Poco::SharedPtr getPool(const std::string& qmgrName); + /// Get a pool of queuemanagers from the cache. + + Poco::SharedPtr createPool(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation); + +private: + + Poco::ExpireCache _cache; +}; + +}} // Namespace MQ::Web + +#endif // _MQ_QueueManagerPoolCache_h diff --git a/MQWeb/src/QueueManagerPoolCache.cpp b/MQWeb/src/QueueManagerPoolCache.cpp new file mode 100644 index 0000000..da5c456 --- /dev/null +++ b/MQWeb/src/QueueManagerPoolCache.cpp @@ -0,0 +1,87 @@ +/* + * Copyright 2010 MQWeb - Franky Braem + * + * Licensed under the EUPL, Version 1.1 or – as soon they + * will be approved by the European Commission - subsequent + * versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the + * Licence. + * You may obtain a copy of the Licence at: + * + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in + * writing, software distributed under the Licence is + * distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the Licence for the specific language governing + * permissions and limitations under the Licence. + */ +#include "MQ/Web/QueueManagerPoolCache.h" + +namespace MQ { +namespace Web { + +QueueManagerFactory::QueueManagerFactory(const std::string& qmgrName) +: _qmgrName(qmgrName) +{ +} + +QueueManagerFactory::QueueManagerFactory(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation) +: _qmgrName(qmgrName) +, _connectionInformation(connectionInformation) +{ +} + +QueueManagerFactory::QueueManagerFactory(const QueueManagerFactory& copy) +: _qmgrName(copy._qmgrName) +{ +} + +QueueManagerFactory::~QueueManagerFactory() +{ +} + +QueueManager::Ptr QueueManagerFactory::createObject() +{ + return new QueueManager(_qmgrName); +} + +void QueueManagerFactory::activateObject(QueueManager::Ptr qmgr) +{ + if ( !qmgr->connected() ) + { + if ( _connectionInformation.size() == 0 ) + { + qmgr->connect(); + } + else + { + qmgr->connect(_connectionInformation); + } + } +} + +QueueManagerPoolCache::QueueManagerPoolCache() +{ +} + +QueueManagerPoolCache::~QueueManagerPoolCache() +{ +} + +Poco::SharedPtr QueueManagerPoolCache::getPool(const std::string& qmgrName) +{ + return _cache.get(qmgrName); +} + +Poco::SharedPtr QueueManagerPoolCache::createPool(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation) +{ + QueueManagerFactory qmgrFactory(qmgrName, connectionInformation); + Poco::SharedPtr pool = new QueueManagerPool(qmgrFactory, 10, 20); + _cache.add(qmgrName, pool); + return pool; +} + +} } // Namespace MQ From 58808f87cae6bfd1bf75ef215820c7fd288497d8 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Mon, 20 Oct 2014 08:00:29 +0200 Subject: [PATCH 120/143] add toString in Poco::format for certValPolicyTable --- MQ/src/QueueManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQ/src/QueueManager.cpp b/MQ/src/QueueManager.cpp index 502b9c7..254a480 100644 --- a/MQ/src/QueueManager.cpp +++ b/MQ/src/QueueManager.cpp @@ -185,7 +185,7 @@ void QueueManager::connect(const std::string& channel, const std::string& server std::map::iterator certValPolicyIterator = certValPolicyTable.find(certValPolicy.toString()); if ( certValPolicyIterator == certValPolicyTable.end() ) { - throw Poco::NotFoundException(Poco::format("Unknown Certification Validation Policy: %s", certValPolicy)); + throw Poco::NotFoundException(Poco::format("Unknown Certification Validation Policy: %s", certValPolicy.toString())); } else { From ed1530266c27a478dbbbbf7ff8f2010f10a6a3cc Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 20 Oct 2014 21:01:17 +0200 Subject: [PATCH 121/143] Initialisation of static variable in class method is not thread-safe --- MQWeb/include/MQ/Web/MQMapper.h | 2 ++ MQWeb/src/MQMapper.cpp | 34 ++++++++++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/MQWeb/include/MQ/Web/MQMapper.h b/MQWeb/include/MQ/Web/MQMapper.h index e10e84c..51deb8b 100644 --- a/MQWeb/include/MQ/Web/MQMapper.h +++ b/MQWeb/include/MQ/Web/MQMapper.h @@ -93,6 +93,8 @@ class MQMapper : public Mapper static DictionaryCache _dictionaryCache; PCF::Ptr _pcf; + + static Dictionary _operators; }; template diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index f91ed27..8ea4c7a 100644 --- a/MQWeb/src/MQMapper.cpp +++ b/MQWeb/src/MQMapper.cpp @@ -30,6 +30,22 @@ namespace Web { DictionaryCache MQMapper::_dictionaryCache; +Dictionary MQMapper::_operators = Dictionary() + (MQCFOP_LESS, "LT") + (MQCFOP_LESS | MQCFOP_EQUAL, "LE") + (MQCFOP_EQUAL, "EQ") + (MQCFOP_GREATER, "GT") + (MQCFOP_GREATER | MQCFOP_EQUAL, "GE") + (MQCFOP_NOT_LESS, "NLT") + (MQCFOP_NOT_EQUAL, "NE") + (MQCFOP_NOT_GREATER, "NGT") + (MQCFOP_LIKE, "LK") + (MQCFOP_NOT_LIKE, "NL") + (MQCFOP_CONTAINS, "CT") + (MQCFOP_EXCLUDES, "EX") + (MQCFOP_CONTAINS_GEN, "CTG") + (MQCFOP_EXCLUDES_GEN, "EXG") +; MQMapper::MQMapper(CommandServer& commandServer, const std::string& objectType, Poco::JSON::Object::Ptr input) : _commandServer(commandServer) @@ -59,23 +75,7 @@ std::string MQMapper::getReasonString(MQLONG reasonCode) MQLONG MQMapper::getOperator(const std::string& op) { - static Dictionary operators = Dictionary() - (MQCFOP_LESS, "LT") - (MQCFOP_LESS | MQCFOP_EQUAL, "LE") - (MQCFOP_EQUAL, "EQ") - (MQCFOP_GREATER, "GT") - (MQCFOP_GREATER | MQCFOP_EQUAL, "GE") - (MQCFOP_NOT_LESS, "NLT") - (MQCFOP_NOT_EQUAL, "NE") - (MQCFOP_NOT_GREATER, "NGT") - (MQCFOP_LIKE, "LK") - (MQCFOP_NOT_LIKE, "NL") - (MQCFOP_CONTAINS, "CT") - (MQCFOP_EXCLUDES, "EX") - (MQCFOP_CONTAINS_GEN, "CTG") - (MQCFOP_EXCLUDES_GEN, "EXG") - ; - return operators.getId(op); + return _operators.getId(op); } const DisplayMap& MQMapper::getDisplayMap(const std::string& objectType, MQLONG id) From 8d6d0995fce11a3485b41a59d98ab9c0915c1806 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 20 Oct 2014 21:02:47 +0200 Subject: [PATCH 122/143] isJSON returns always true, except for WebController --- MQWeb/include/MQ/Web/Controller.h | 10 ++++++++-- MQWeb/include/MQ/Web/WebController.h | 7 +++++++ MQWeb/src/Controller.cpp | 19 ------------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/MQWeb/include/MQ/Web/Controller.h b/MQWeb/include/MQ/Web/Controller.h index cd48096..227a590 100644 --- a/MQWeb/include/MQ/Web/Controller.h +++ b/MQWeb/include/MQ/Web/Controller.h @@ -86,8 +86,9 @@ class Controller : public Poco::Net::PartHandler bool isGet() const; /// Returns true when the HTTP method GET is used. - bool isJSON() const; - /// Returns true when application/json + virtual bool isJSON() const; + /// Return true when the view is a JSON view. + /// Default is true. bool isPost() const; /// Returns true when the HTTP method POST is used. @@ -203,6 +204,11 @@ inline bool Controller::isGet() const } +inline bool Controller::isJSON() const +{ + return true; +} + inline bool Controller::isPost() const { return _request->getMethod().compare("POST") == 0; diff --git a/MQWeb/include/MQ/Web/WebController.h b/MQWeb/include/MQ/Web/WebController.h index 8c32934..fbbc57c 100644 --- a/MQWeb/include/MQ/Web/WebController.h +++ b/MQWeb/include/MQ/Web/WebController.h @@ -41,6 +41,8 @@ class WebController : public MQController virtual const std::map& getActions() const; /// Returns all available actions + bool isJSON() const; + void qmgr(); void queue(); @@ -72,6 +74,11 @@ inline const Controller::ActionMap& WebController::getActions() const return actions; } +inline bool WebController::isJSON() const +{ + return false; +} + } } // Namespace MQ::Web #endif // _MQWeb_WebController_h diff --git a/MQWeb/src/Controller.cpp b/MQWeb/src/Controller.cpp index d0264aa..f9d5b4f 100644 --- a/MQWeb/src/Controller.cpp +++ b/MQWeb/src/Controller.cpp @@ -136,25 +136,6 @@ void Controller::handle(const std::vector& parameters, Poco::Net::H } -bool Controller::isJSON() const -{ - bool result = false; - - std::string accept; - try - { - accept = _request->get("Accept"); - Poco::Net::MediaType mediaType(accept.substr(0, accept.find_first_of(','))); - result = mediaType.matches("application", "json"); - } - catch(Poco::NotFoundException&) - { - // Ignore - } - - return result; -} - void Controller::setJSONView() { if ( _form.has("callback") ) setView(new JSONPView(_form.get("callback"))); From e14c233f00059ea90fc7544c04c322d0f3d47fc2 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 20 Oct 2014 21:03:58 +0200 Subject: [PATCH 123/143] Use DynamicStruct and check elements with contains method --- MQ/include/MQ/QueueManager.h | 4 +-- MQ/src/QueueManager.cpp | 57 ++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/MQ/include/MQ/QueueManager.h b/MQ/include/MQ/QueueManager.h index 02b8ea2..22c1da1 100644 --- a/MQ/include/MQ/QueueManager.h +++ b/MQ/include/MQ/QueueManager.h @@ -52,7 +52,7 @@ class QueueManager /// Connects to the queuemanager. Only use this method when the Websphere /// MQ system is loaded in client mode. Can throw an MQException. - void connect(const std::string& channel, const std::string& server, const Poco::Dynamic::Struct& ssl); + void connect(const std::string& channel, const std::string& server, const Poco::DynamicStruct& ssl); /// Connects to the queuemanager using a channel that is protected with SSL. /// The configuration for SSL is based on the following properties: keyrepos (required), /// cipherspec, fips, suiteb and certificate_validation_policy (only when @@ -60,7 +60,7 @@ class QueueManager /// Only use this method when MQ system is loaded in client mode. Can /// throw an MQException. - void connect(const Poco::Dynamic::Struct& connectionInformation); + void connect(const Poco::DynamicStruct& connectionInformation); /// Connect using the information stored in the Poco::Dynamic::Struct object /// Can throw an MQException diff --git a/MQ/src/QueueManager.cpp b/MQ/src/QueueManager.cpp index 254a480..64d3dd0 100644 --- a/MQ/src/QueueManager.cpp +++ b/MQ/src/QueueManager.cpp @@ -85,15 +85,11 @@ void QueueManager::connect(const std::string& channel, const std::string& server } -void QueueManager::connect(const Poco::Dynamic::Struct& connectionInformation) +void QueueManager::connect(const Poco::DynamicStruct& connectionInformation) { - Poco::Dynamic::Var ssl = connectionInformation["ssl"]; - if ( ssl.isEmpty() ) - { - connect(connectionInformation["channel"], connectionInformation["connection"]); - } - else + if ( connectionInformation.contains("ssl") ) { + Poco::Dynamic::Var ssl = connectionInformation["ssl"]; if ( ssl.isStruct() ) { connect(connectionInformation["channel"], @@ -101,9 +97,20 @@ void QueueManager::connect(const Poco::Dynamic::Struct& connectionI ssl.extract >()); } } + else + { + if ( connectionInformation.contains("channel") && connectionInformation.contains("connection") ) + { + connect(connectionInformation["channel"], connectionInformation["connection"]); + } + else + { + connect(); + } + } } -void QueueManager::connect(const std::string& channel, const std::string& server, const Poco::Dynamic::Struct& ssl) +void QueueManager::connect(const std::string& channel, const std::string& server, const Poco::DynamicStruct& ssl) { MQCNO cno = { MQCNO_DEFAULT }; @@ -118,12 +125,12 @@ void QueueManager::connect(const std::string& channel, const std::string& server strncpy(cd.ChannelName, channel.c_str(), MQ_CHANNEL_NAME_LENGTH); strncpy(cd.ConnectionName, server.c_str(), MQ_CONN_NAME_LENGTH); - Poco::Dynamic::Var cipherspec = ssl["cipherspec"]; - if ( !cipherspec.isEmpty() ) + if ( ssl.contains("cipherspec") ) { - strncpy(cd.SSLCipherSpec, cipherspec.toString().c_str(), MQ_SSL_CIPHER_SPEC_LENGTH); + strncpy(cd.SSLCipherSpec, ssl["cipherspec"].toString().c_str(), MQ_SSL_CIPHER_SPEC_LENGTH); cd.Version = MQCD_VERSION_7; // SSL requires MQCD version 7 or later } + cd.TransportType = MQXPT_TCP; cno.ClientConnPtr = &cd; @@ -133,15 +140,16 @@ void QueueManager::connect(const std::string& channel, const std::string& server Poco::Dynamic::Var keyrepos = ssl["keyrepos"]; strncpy(sco.KeyRepository, keyrepos.toString().c_str(), MQ_SSL_KEY_REPOSITORY_LENGTH); - Poco::Dynamic::Var fips = ssl["fips"]; - if ( !fips.isEmpty() && fips.convert() ) + if ( ssl.contains("fips") ) { - sco.FipsRequired = MQSSL_FIPS_YES; - sco.Version = MQSCO_VERSION_2; // A version 2 MQSCO supports FipsRequired + if ( ssl["fips"].convert() ) + { + sco.FipsRequired = MQSSL_FIPS_YES; + sco.Version = MQSCO_VERSION_2; // A version 2 MQSCO supports FipsRequired + } } - Poco::Dynamic::Var suiteb = ssl["suiteb"]; - if ( ! suiteb.isEmpty() ) + if ( ssl.contains("suiteb") ) { static std::map suiteBTable; if ( suiteBTable.size() == 0 ) @@ -153,7 +161,7 @@ void QueueManager::connect(const std::string& channel, const std::string& server sco.Version = MQSCO_VERSION_3; /* A version 3 MQSCO supports Suite B encryption policy */ - Poco::StringTokenizer tokenizer(suiteb.toString(), ",", Poco::StringTokenizer::TOK_TRIM); + Poco::StringTokenizer tokenizer(ssl["suiteb"].toString(), ",", Poco::StringTokenizer::TOK_TRIM); int n = 0; for(Poco::StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end() && n < 4; ++it, ++n) { @@ -170,8 +178,7 @@ void QueueManager::connect(const std::string& channel, const std::string& server } #ifdef MQSCO_VERSION_4 - Poco::Dynamic::Var certValPolicy = ssl["certificate_validation_policy"]; - if ( !certValPolicy.isEmpty() ) + if ( ssl.contains("certificate_validation_policy") ) { static std::map certValPolicyTable; if ( certValPolicyTable.size() == 0 ) @@ -182,10 +189,11 @@ void QueueManager::connect(const std::string& channel, const std::string& server sco.Version = MQSCO_VERSION_4; /* A version 4 MQSCO supports certificate validation policy */ - std::map::iterator certValPolicyIterator = certValPolicyTable.find(certValPolicy.toString()); + std::string certValPolicy = ssl["certificate_validation_policy"].toString(); + std::map::iterator certValPolicyIterator = certValPolicyTable.find(certValPolicy); if ( certValPolicyIterator == certValPolicyTable.end() ) { - throw Poco::NotFoundException(Poco::format("Unknown Certification Validation Policy: %s", certValPolicy.toString())); + throw Poco::NotFoundException(Poco::format("Unknown Certification Validation Policy: %s", certValPolicy)); } else { @@ -193,14 +201,13 @@ void QueueManager::connect(const std::string& channel, const std::string& server } } #endif - Poco::Dynamic::Var ocsp = ssl["ocsp_url"]; - if ( !ocsp.isEmpty() ) + if ( ssl.contains("ocsp_url") ) { /* OCSP requires MQAIR version 2 or later */ authInfoRec.Version = MQAIR_VERSION_2; authInfoRec.AuthInfoType = MQAIT_OCSP; - strncpy(authInfoRec.OCSPResponderURL, ocsp.toString().c_str(), MQ_AUTH_INFO_OCSP_URL_LENGTH); + strncpy(authInfoRec.OCSPResponderURL, ssl["ocsp_url"].toString().c_str(), MQ_AUTH_INFO_OCSP_URL_LENGTH); /* The MQSCO must point to the MQAIR */ sco.AuthInfoRecCount = 1; From 33f1d8c9e0b6cd6e136b8382ba09bb9799f15407 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 20 Oct 2014 21:11:34 +0200 Subject: [PATCH 124/143] Working on connection pooling ... --- MQ/include/MQ/QueueManagerPool.h | 64 ++++++++++- MQ/src/QueueManagerPool.cpp | 52 +++++++++ MQWeb/include/MQ/Web/MQController.h | 9 +- MQWeb/include/MQ/Web/QueueManagerPoolCache.h | 31 +----- MQWeb/src/MQController.cpp | 91 +++++---------- MQWeb/src/QueueManagerPoolCache.cpp | 111 ++++++++++++------- 6 files changed, 229 insertions(+), 129 deletions(-) diff --git a/MQ/include/MQ/QueueManagerPool.h b/MQ/include/MQ/QueueManagerPool.h index 8eb5d91..e5b3e96 100644 --- a/MQ/include/MQ/QueueManagerPool.h +++ b/MQ/include/MQ/QueueManagerPool.h @@ -29,23 +29,83 @@ namespace MQ { +class QueueManagerFactory : public Poco::PoolableObjectFactory +{ +public: + QueueManagerFactory(const std::string& qmgrName); + + QueueManagerFactory(const std::string& qmgrName, const Poco::DynamicStruct& connectionInformation); + + QueueManagerFactory(const QueueManagerFactory& factory); + + virtual ~QueueManagerFactory(); + + QueueManager::Ptr createObject(); + + void activateObject(QueueManager::Ptr qmgr); + +private: + + std::string _qmgrName; + + Poco::DynamicStruct _connectionInformation; +}; + + + class QueueManagerPool /// This class implements a Queuemanager pool { public: - typedef Poco::PoolableObjectFactory QueueManagerFactory; - QueueManagerPool(const QueueManagerFactory& factory, std::size_t capacity, std::size_t peakCapacity); /// Constructor. virtual ~QueueManagerPool(); /// Destructor. + QueueManager::Ptr getQueueManager(); + + void release(QueueManager::Ptr qmgr); + private: Poco::ObjectPool _pool; }; +inline QueueManager::Ptr QueueManagerPool::getQueueManager() +{ + return _pool.borrowObject(); +} + +inline void QueueManagerPool::release(QueueManager::Ptr qmgr) +{ + _pool.returnObject(qmgr); +} + + +class QueueManagerPoolGuard +{ +public: + QueueManagerPoolGuard(Poco::SharedPtr pool); + + ~QueueManagerPoolGuard(); + + QueueManager::Ptr getQueueManager() const; + +private: + QueueManagerPoolGuard(const QueueManagerPoolGuard&); + QueueManagerPoolGuard& operator= (const QueueManagerPoolGuard&); + + Poco::SharedPtr _pool; + + QueueManager::Ptr _qmgr; +}; + +inline QueueManager::Ptr QueueManagerPoolGuard::getQueueManager() const +{ + return _qmgr; +} + } // Namespace MQ #endif // _MQ_QueueManagerPool_h diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index ea685d7..54e277b 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -24,6 +24,47 @@ namespace MQ { +QueueManagerFactory::QueueManagerFactory(const std::string& qmgrName) +: _qmgrName(qmgrName) +{ +} + +QueueManagerFactory::QueueManagerFactory(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation) +: _qmgrName(qmgrName) +, _connectionInformation(connectionInformation) +{ +} + +QueueManagerFactory::QueueManagerFactory(const QueueManagerFactory& copy) +: _qmgrName(copy._qmgrName) +, _connectionInformation(copy._connectionInformation) +{ +} + +QueueManagerFactory::~QueueManagerFactory() +{ +} + +QueueManager::Ptr QueueManagerFactory::createObject() +{ + return new QueueManager(_qmgrName); +} + +void QueueManagerFactory::activateObject(QueueManager::Ptr qmgr) +{ + if ( !qmgr->connected() ) + { + if ( _connectionInformation.size() == 0 ) + { + qmgr->connect(); + } + else + { + qmgr->connect(_connectionInformation); + } + } +} + QueueManagerPool::QueueManagerPool(const QueueManagerFactory& factory, std::size_t capacity, std::size_t peakCapacity) : _pool(factory, capacity, peakCapacity) { @@ -34,4 +75,15 @@ QueueManagerPool::~QueueManagerPool() { } +QueueManagerPoolGuard::QueueManagerPoolGuard(Poco::SharedPtr pool) + : _pool(pool) + , _qmgr(pool->getQueueManager()) +{ +} + +QueueManagerPoolGuard::~QueueManagerPoolGuard() +{ + _pool->release(_qmgr); +} + } // Namespace MQ diff --git a/MQWeb/include/MQ/Web/MQController.h b/MQWeb/include/MQ/Web/MQController.h index 0161e9f..fa5ef3a 100644 --- a/MQWeb/include/MQ/Web/MQController.h +++ b/MQWeb/include/MQ/Web/MQController.h @@ -28,6 +28,7 @@ #include "MQ/CommandServer.h" #include "MQ/MQException.h" #include "MQ/Web/Controller.h" +#include "MQ/Web/QueueManagerPoolCache.h" namespace MQ { namespace Web { @@ -77,7 +78,10 @@ class MQController : public Controller private: - QueueManager::Ptr _qmgr; + Poco::SharedPtr _qmgrPoolGuard; + + + Poco::SharedPtr _qmgr; CommandServer::Ptr _commandServer; @@ -87,6 +91,9 @@ class MQController : public Controller Poco::Stopwatch _stopwatch; + + + static QueueManagerPoolCache _cache; }; diff --git a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h index db9fc59..ccb7746 100644 --- a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h +++ b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h @@ -29,28 +29,6 @@ namespace MQ { namespace Web { -class QueueManagerFactory : public QueueManagerPool::QueueManagerFactory -{ -public: - QueueManagerFactory(const std::string& qmgrName); - - QueueManagerFactory(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation); - - QueueManagerFactory(const QueueManagerFactory& factory); - - virtual ~QueueManagerFactory(); - - QueueManager::Ptr createObject(); - - void activateObject(QueueManager::Ptr qmgr); - -private: - - std::string _qmgrName; - - Poco::Dynamic::Struct _connectionInformation; -}; - class QueueManagerPoolCache /// This class implements a cache for queuemanager pools { @@ -62,14 +40,15 @@ class QueueManagerPoolCache virtual ~QueueManagerPoolCache(); /// Destructor. - Poco::SharedPtr getPool(const std::string& qmgrName); - /// Get a pool of queuemanagers from the cache. - - Poco::SharedPtr createPool(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation); + Poco::SharedPtr getQueueManager(const std::string& qmgrName); private: + Poco::SharedPtr createPool(const std::string& qmgrName); + Poco::ExpireCache _cache; + + Poco::Mutex _mutex; }; }} // Namespace MQ::Web diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index edeac56..c44031a 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -19,6 +19,7 @@ * permissions and limitations under the Licence. */ #include "Poco/Util/Application.h" +#include "Poco/Dynamic/Struct.h" #include "Poco/JSON/Object.h" #include "MQ/MQSubsystem.h" @@ -32,6 +33,7 @@ namespace MQ { namespace Web { +QueueManagerPoolCache MQController::_cache; MQController::MQController() : Controller(), _mqwebData(new Poco::JSON::Object()) { @@ -55,97 +57,53 @@ void MQController::beforeAction() MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); Poco::Util::LayeredConfiguration& config = Poco::Util::Application::instance().config(); - const std::vector& parameters = getParameters(); - _mqwebData->set("client", mqSystem.client()); + std::string qmgrName; if ( config.hasProperty("mq.web.qmgr") ) { // When a queuemanager is passed on the command line, we always // connect to this queuemanager. When the user specified another // queuemanager on the URL, it will be ignored. - _qmgr = new QueueManager(config.getString("mq.web.qmgr")); + qmgrName = config.getString("mq.web.qmgr"); } else { + const std::vector& parameters = getParameters(); if ( parameters.size() > 0 ) { - _qmgr = new QueueManager(parameters[0]); + qmgrName = parameters[0]; } - else + else if ( mqSystem.client() ) { - if ( mqSystem.client() ) - { - _qmgr = new QueueManager(config.getString("mq.web.defaultQmgr", "*")); - } - else // In bindings mode we can connect to the default queuemanager - { - _qmgr = new QueueManager(); - } + qmgrName = config.getString("mq.web.defaultQmgr", "*"); } } - if ( mqSystem.binding() ) - { - _qmgr->connect(); - } - else - { - // In client mode we check for a configuration - // When this is not available, we hope that a channel tab file - // is configured. - std::string qmgrConfig = "mq.web.qmgr." + _qmgr->name(); - std::string qmgrConfigConnection = qmgrConfig + ".connection"; - if ( config.has(qmgrConfigConnection) ) - { - std::string connection; - std::string channel; - connection = config.getString(qmgrConfigConnection); - std::string qmgrConfigChannel = qmgrConfig + ".channel"; - if ( config.has(qmgrConfigChannel) ) - { - channel = config.getString(qmgrConfigChannel); - } - else - { - channel = config.getString("mq.web.defaultChannel", "SYSTEM.DEF.SVRCONN"); - } - if ( config.has("mq.web.ssl.keyrepos") ) - { - Poco::AutoPtr sslConfig = config.createView("mq.web.ssl"); - _qmgr->connect(channel, connection, *sslConfig.get()); - } - else - { - _qmgr->connect(channel, connection); - } - } - else // Hope that there is a channel tab file available - { - _qmgr->connect(); - } - } + _qmgrPoolGuard = _cache.getQueueManager(qmgrName); + _qmgr = _qmgrPoolGuard->getQueueManager(); + + std::string qmgrConfig = "mq.web.qmgr." + qmgrName; _mqwebData->set("qmgr", _qmgr->name()); _mqwebData->set("zos", _qmgr->zos()); _mqwebData->set("qmgrId", _qmgr->id()); - std::string qmgrConfig = "mq.web.qmgr." + _qmgr->name(); - std::string qmgrConfigModel = qmgrConfig + ".reply"; + std::string qmgrConfigReplyQ = qmgrConfig + ".reply"; - std::string modelQ; - if ( config.has(qmgrConfigModel) ) + std::string replyQ; + if ( config.has(qmgrConfigReplyQ) ) { - modelQ = config.getString(qmgrConfigModel); + replyQ = config.getString(qmgrConfigReplyQ); } else { - modelQ = config.getString("mq.web.reply", "SYSTEM.DEFAULT.MODEL.QUEUE"); + replyQ = config.getString("mq.web.reply", "SYSTEM.DEFAULT.MODEL.QUEUE"); } - _mqwebData->set("replyq", modelQ); + _mqwebData->set("replyq", replyQ); _mqwebData->set("cmdq", _qmgr->commandQueue()); - _commandServer = new CommandServer(_qmgr, modelQ); + _commandServer = new CommandServer(_qmgr, replyQ); } @@ -168,7 +126,14 @@ void MQController::handleException(const MQException& mqe) reason->set("code", mqe.reason()); reason->set("desc", MQMapper::getReasonString(mqe.reason())); - setJSONView(); + if ( isJSON() ) + { + setJSONView(); + } + else + { + setView(new TemplateView("error.tpl")); + } } @@ -196,7 +161,7 @@ void MQController::handle(const std::vector& parameters, Poco::Net: catch(MQException& mqe) { handleException(mqe); - render(); + afterAction(); } catch(...) { diff --git a/MQWeb/src/QueueManagerPoolCache.cpp b/MQWeb/src/QueueManagerPoolCache.cpp index da5c456..74ff36b 100644 --- a/MQWeb/src/QueueManagerPoolCache.cpp +++ b/MQWeb/src/QueueManagerPoolCache.cpp @@ -18,68 +18,105 @@ * See the Licence for the specific language governing * permissions and limitations under the Licence. */ +#include "Poco/Util/Application.h" + +#include "MQ/MQSubsystem.h" + #include "MQ/Web/QueueManagerPoolCache.h" namespace MQ { namespace Web { -QueueManagerFactory::QueueManagerFactory(const std::string& qmgrName) -: _qmgrName(qmgrName) -{ -} -QueueManagerFactory::QueueManagerFactory(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation) -: _qmgrName(qmgrName) -, _connectionInformation(connectionInformation) +QueueManagerPoolCache::QueueManagerPoolCache() { } -QueueManagerFactory::QueueManagerFactory(const QueueManagerFactory& copy) -: _qmgrName(copy._qmgrName) +QueueManagerPoolCache::~QueueManagerPoolCache() { } -QueueManagerFactory::~QueueManagerFactory() +Poco::SharedPtr QueueManagerPoolCache::getQueueManager(const std::string& qmgrName) { -} + Poco::SharedPtr pool = _cache.get(qmgrName); + if ( pool.isNull() ) + { + Poco::Mutex::ScopedLock lock(_mutex); + pool = _cache.get(qmgrName); // Check it again ... + if ( pool.isNull() ) + { + pool = createPool(qmgrName); + if ( pool.isNull() ) + { + //TODO: throw exception ... + } + } + } -QueueManager::Ptr QueueManagerFactory::createObject() -{ - return new QueueManager(_qmgrName); + return new QueueManagerPoolGuard(pool); } -void QueueManagerFactory::activateObject(QueueManager::Ptr qmgr) +Poco::SharedPtr QueueManagerPoolCache::createPool(const std::string& qmgrName) { - if ( !qmgr->connected() ) + Poco::SharedPtr pool; + + MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); + Poco::Util::LayeredConfiguration& config = Poco::Util::Application::instance().config(); + + std::string qmgrConfig = "mq.web.qmgr." + qmgrName; + + if ( mqSystem.client() ) { - if ( _connectionInformation.size() == 0 ) + Poco::DynamicStruct connectionInformation; + + // In client mode we check for a configuration + // When this is not available, we hope that a channel tab file + // is configured. + std::string qmgrConfigConnection = qmgrConfig + ".connection"; + if ( config.has(qmgrConfigConnection) ) { - qmgr->connect(); + std::string connection; + std::string channel; + connectionInformation.insert("connection", config.getString(qmgrConfigConnection)); + std::string qmgrConfigChannel = qmgrConfig + ".channel"; + if ( config.has(qmgrConfigChannel) ) + { + connectionInformation.insert("channel", config.getString(qmgrConfigChannel)); + } + else + { + connectionInformation.insert("channel", config.getString("mq.web.defaultChannel", "SYSTEM.DEF.SVRCONN")); + } + + if ( config.has("mq.web.ssl.keyrepos") ) + { + Poco::DynamicStruct ssl; + connectionInformation.insert("ssl", ssl); + + Poco::Util::AbstractConfiguration::Keys keys; + Poco::AutoPtr sslConfig = config.createView("mq.web.ssl"); + sslConfig->keys(keys); + for(Poco::Util::AbstractConfiguration::Keys::iterator it = keys.begin(); it != keys.end(); ++it) + { + ssl.insert(*it, config.getString(*it)); + } + } + + QueueManagerFactory qmgrFactory(qmgrName, connectionInformation); + pool = new QueueManagerPool(qmgrFactory, 10, 20); } else { - qmgr->connect(_connectionInformation); + QueueManagerFactory qmgrFactory(qmgrName); + pool = new QueueManagerPool(qmgrFactory, 10, 20); } } -} - -QueueManagerPoolCache::QueueManagerPoolCache() -{ -} - -QueueManagerPoolCache::~QueueManagerPoolCache() -{ -} - -Poco::SharedPtr QueueManagerPoolCache::getPool(const std::string& qmgrName) -{ - return _cache.get(qmgrName); -} + else + { + QueueManagerFactory qmgrFactory(qmgrName); + pool = new QueueManagerPool(qmgrFactory, 10, 20); + } -Poco::SharedPtr QueueManagerPoolCache::createPool(const std::string& qmgrName, const Poco::Dynamic::Struct& connectionInformation) -{ - QueueManagerFactory qmgrFactory(qmgrName, connectionInformation); - Poco::SharedPtr pool = new QueueManagerPool(qmgrFactory, 10, 20); _cache.add(qmgrName, pool); return pool; } From fdbb665ebdcc3049415af98b6f8f5b8da164c5ba Mon Sep 17 00:00:00 2001 From: fbraem Date: Wed, 22 Oct 2014 16:40:34 +0200 Subject: [PATCH 125/143] Add PoolGuard class and use typedef for QueueManagerPool --- MQ/include/MQ/QueueManagerPool.h | 61 ++++++-------------- MQ/src/QueueManagerPool.cpp | 21 ------- MQWeb/include/MQ/Web/QueueManagerPoolCache.h | 3 + MQWeb/src/MQController.cpp | 2 +- 4 files changed, 21 insertions(+), 66 deletions(-) diff --git a/MQ/include/MQ/QueueManagerPool.h b/MQ/include/MQ/QueueManagerPool.h index e5b3e96..eff4ee0 100644 --- a/MQ/include/MQ/QueueManagerPool.h +++ b/MQ/include/MQ/QueueManagerPool.h @@ -52,60 +52,33 @@ class QueueManagerFactory : public Poco::PoolableObjectFactory _pool; -}; - -inline QueueManager::Ptr QueueManagerPool::getQueueManager() -{ - return _pool.borrowObject(); -} - -inline void QueueManagerPool::release(QueueManager::Ptr qmgr) -{ - _pool.returnObject(qmgr); -} - - -class QueueManagerPoolGuard +template +class PoolGuard { public: - QueueManagerPoolGuard(Poco::SharedPtr pool); + PoolGuard(Poco::SharedPtr pool) : _pool(pool), _object(pool->borrowObject()) + { + } - ~QueueManagerPoolGuard(); + ~PoolGuard() + { + if ( ! _object.isNull() ) _pool->returnObject(_object); + } - QueueManager::Ptr getQueueManager() const; + Poco::SharedPtr getObject() const + { + return _object; + } private: - QueueManagerPoolGuard(const QueueManagerPoolGuard&); - QueueManagerPoolGuard& operator= (const QueueManagerPoolGuard&); + PoolGuard(const PoolGuard&); + PoolGuard& operator= (const PoolGuard&); - Poco::SharedPtr _pool; + Poco::SharedPtr _pool; - QueueManager::Ptr _qmgr; + Poco::SharedPtr _object; }; -inline QueueManager::Ptr QueueManagerPoolGuard::getQueueManager() const -{ - return _qmgr; -} - } // Namespace MQ #endif // _MQ_QueueManagerPool_h diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index 54e277b..3e73ccd 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -65,25 +65,4 @@ void QueueManagerFactory::activateObject(QueueManager::Ptr qmgr) } } -QueueManagerPool::QueueManagerPool(const QueueManagerFactory& factory, std::size_t capacity, std::size_t peakCapacity) -: _pool(factory, capacity, peakCapacity) -{ -} - - -QueueManagerPool::~QueueManagerPool() -{ -} - -QueueManagerPoolGuard::QueueManagerPoolGuard(Poco::SharedPtr pool) - : _pool(pool) - , _qmgr(pool->getQueueManager()) -{ -} - -QueueManagerPoolGuard::~QueueManagerPoolGuard() -{ - _pool->release(_qmgr); -} - } // Namespace MQ diff --git a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h index ccb7746..7fd4e90 100644 --- a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h +++ b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h @@ -29,6 +29,9 @@ namespace MQ { namespace Web { +typedef Poco::ObjectPool QueueManagerPool; +typedef PoolGuard QueueManagerPoolGuard; + class QueueManagerPoolCache /// This class implements a cache for queuemanager pools { diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index c44031a..ac9b7d6 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -81,7 +81,7 @@ void MQController::beforeAction() } _qmgrPoolGuard = _cache.getQueueManager(qmgrName); - _qmgr = _qmgrPoolGuard->getQueueManager(); + _qmgr = _qmgrPoolGuard->getObject(); std::string qmgrConfig = "mq.web.qmgr." + qmgrName; From 6b192b3f5ff384c7064b48fa44a7b35b7bc27208 Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 23 Oct 2014 22:52:24 +0200 Subject: [PATCH 126/143] Still working on connection pooling ... --- MQ/include/MQ/CommandServer.h | 27 +-- MQ/include/MQ/Queue.h | 4 +- MQ/include/MQ/QueueManager.h | 30 +++ MQ/include/MQ/QueueManagerPool.h | 220 ++++++++++++++++++- MQ/src/CommandServer.cpp | 12 +- MQ/src/Queue.cpp | 12 +- MQ/src/QueueManagerPool.cpp | 12 +- MQWeb/include/MQ/Web/MQController.h | 7 +- MQWeb/include/MQ/Web/QueueManagerPoolCache.h | 5 +- MQWeb/src/MQController.cpp | 22 +- MQWeb/src/MessageController.cpp | 6 +- MQWeb/src/QueueManagerPoolCache.cpp | 8 +- 12 files changed, 298 insertions(+), 67 deletions(-) diff --git a/MQ/include/MQ/CommandServer.h b/MQ/include/MQ/CommandServer.h index 85c074c..aba01a0 100644 --- a/MQ/include/MQ/CommandServer.h +++ b/MQ/include/MQ/CommandServer.h @@ -25,7 +25,6 @@ #include #include -#include "MQ/QueueManager.h" #include "MQ/Queue.h" #include "MQ/PCF.h" @@ -33,13 +32,12 @@ namespace MQ { +class QueueManager; + class CommandServer /// Class for sending PCF commands to a queuemanager { public: - CommandServer(QueueManager::Ptr qmgr, const std::string& modelQueue); - /// Constructor. - PCF::Ptr createCommand(MQLONG command) const; /// Returns a shared pointer to a PCF object for the given command. @@ -47,27 +45,24 @@ class CommandServer /// Sends the command to the queuemanager. The response is returned /// as a vector of PCF objects. Can throw a MQException. - const QueueManager& qmgr() const; - /// Returns the associated queuemanager - - typedef Poco::SharedPtr Ptr; - private: - QueueManager::Ptr _qmgr; + CommandServer(QueueManager& qmgr, const std::string& modelQueue); + /// Constructor. + + CommandServer(const CommandServer& copy); + CommandServer& operator = (const CommandServer& copy); + + QueueManager& _qmgr; Queue _commandQ; Queue _replyQ; -}; + friend class QueueManager; +}; -inline const QueueManager& CommandServer::qmgr() const -{ - poco_assert_dbg(!_qmgr.isNull()); // Can't be null - return *_qmgr.get(); -} } // namespace MQ diff --git a/MQ/include/MQ/Queue.h b/MQ/include/MQ/Queue.h index ea08eab..c0e9591 100644 --- a/MQ/include/MQ/Queue.h +++ b/MQ/include/MQ/Queue.h @@ -40,7 +40,7 @@ class Queue /// Represents a Websphere MQ queue { public: - Queue(Poco::SharedPtr qmgr, const std::string& name); + Queue(QueueManager& qmgr, const std::string& name); /// Constructor virtual ~Queue(); @@ -66,7 +66,7 @@ class Queue private: - Poco::SharedPtr _qmgr; + QueueManager& _qmgr; MQHOBJ _handle; diff --git a/MQ/include/MQ/QueueManager.h b/MQ/include/MQ/QueueManager.h index 22c1da1..caa7c74 100644 --- a/MQ/include/MQ/QueueManager.h +++ b/MQ/include/MQ/QueueManager.h @@ -31,6 +31,8 @@ #include "Poco/Dynamic/Struct.h" +#include "MQ/CommandServer.h" + namespace MQ { class QueueManager @@ -45,6 +47,10 @@ class QueueManager virtual ~QueueManager(); /// Destructor. Disconnects the queuemanager when it is still connected. + Poco::SharedPtr commandServer(); + /// Returns the command server for this queuemanager. A command server + /// must be created first with createCommandServer. + void connect(); /// Connects to the queuemanager. Can throw an MQException. @@ -67,6 +73,10 @@ class QueueManager bool connected() const; /// Returns true when the queuemanager is connected. + Poco::SharedPtr createCommandServer(const std::string& replyQ); + /// Create a command server. Once created, you can use commandServer to + /// get the associated command server. Can throw an MQException. + void disconnect(); /// Disconnects from the queuemanager. Can throw an MQException. @@ -90,6 +100,8 @@ class QueueManager MQHCONN _handle; + MQHCONN handle() const; + std::string _name; std::string _id; @@ -98,6 +110,8 @@ class QueueManager MQLONG _applicationType; + Poco::SharedPtr _commandServer; + void inquireQmgrAttrs(); friend class Queue; @@ -126,11 +140,27 @@ inline bool QueueManager::connected() const return _handle != 0L; } +inline MQHCONN QueueManager::handle() const +{ + return _handle; +} + inline bool QueueManager::zos() const { return _applicationType == MQPL_ZOS; } +inline Poco::SharedPtr QueueManager::commandServer() +{ + return _commandServer; +} + +inline Poco::SharedPtr QueueManager::createCommandServer(const std::string& replyQ) +{ + _commandServer = new CommandServer(*this, replyQ); + return _commandServer; +} + } // Namespace MQ #endif // _MQ_QueueManager_h diff --git a/MQ/include/MQ/QueueManagerPool.h b/MQ/include/MQ/QueueManagerPool.h index eff4ee0..0964945 100644 --- a/MQ/include/MQ/QueueManagerPool.h +++ b/MQ/include/MQ/QueueManagerPool.h @@ -25,11 +25,208 @@ #include "MQ/QueueManager.h" +namespace Poco { + +template +class TimedObject +{ +public: + + typedef SharedPtr > Ptr; + + TimedObject(const C& object) : _object(object) + { + } + + ~TimedObject() + { + } + + C& getObject() + { + return _object; + } + + void updateLastUsed() + { + _lastUsed.update(); + } + +private: + + C _object; + + Poco::Timestamp _lastUsed; +}; + + +template +class ObjectPool, P, F> + /// An ObjectPool manages a pool of objects of a certain class. + /// + /// The number of objects managed by the pool can be restricted. + /// + /// When an object is requested from the pool: + /// - If an object is available from the pool, an object from the pool is + /// removed from the pool, activated (using the factory) and returned. + /// - Otherwise, if the peak capacity of the pool has not yet been reached, + /// a new object is created and activated, using the object factory, and returned. + /// - If the peak capacity has already been reached, null is returned. + /// + /// When an object is returned to the pool: + /// - If the object is valid (checked by calling validateObject() + /// from the object factory), the object is deactivated. If the + /// number of objects in the pool is below the capacity, + /// the object is added to the pool. Otherwise it is destroyed. + /// - If the object is not valid, it is destroyed immediately. +{ +public: + + ObjectPool(std::size_t capacity, std::size_t peakCapacity): + /// Creates a new ObjectPool with the given capacity + /// and peak capacity. + /// + /// The PoolableObjectFactory must have a public default constructor. + _capacity(capacity), + _peakCapacity(peakCapacity), + _size(0) + { + poco_assert (capacity <= peakCapacity); + } + + ObjectPool(const F& factory, std::size_t capacity, std::size_t peakCapacity): + /// Creates a new ObjectPool with the given PoolableObjectFactory, + /// capacity and peak capacity. The PoolableObjectFactory must have + /// a public copy constructor. + _factory(factory), + _capacity(capacity), + _peakCapacity(peakCapacity), + _size(0) + { + poco_assert (capacity <= peakCapacity); + } + + ~ObjectPool() + /// Destroys the ObjectPool. + { + for (typename std::vector

::iterator it = _pool.begin(); it != _pool.end(); ++it) + { + _factory.destroyObject(*it); + } + } + + P borrowObject() + /// Obtains an object from the pool, or creates a new object if + /// possible. + /// + /// Returns null if no object is available. + /// + /// If activating the object fails, the object is destroyed and + /// the exception is passed on to the caller. + { + Poco::FastMutex::ScopedLock lock(_mutex); + + if (!_pool.empty()) + { + P pObject = _pool.back(); + _pool.pop_back(); + return activateObject(pObject); + } + else if (_size < _peakCapacity) + { + P pObject = _factory.createObject(); + activateObject(pObject); + _size++; + return pObject; + } + else return 0; + } + + void returnObject(P pObject) + /// Returns an object to the pool. + { + Poco::FastMutex::ScopedLock lock(_mutex); + + if (_factory.validateObject(pObject)) + { + _factory.deactivateObject(pObject); + if (_pool.size() < _capacity) + { + _pool.push_back(pObject); + } + else + { + _factory.destroyObject(pObject); + _size--; + } + } + else + { + _factory.destroyObject(pObject); + } + } + + std::size_t capacity() const + { + return _capacity; + } + + std::size_t peakCapacity() const + { + return _peakCapacity; + } + + std::size_t size() const + { + Poco::FastMutex::ScopedLock lock(_mutex); + + return _size; + } + + std::size_t available() const + { + Poco::FastMutex::ScopedLock lock(_mutex); + + return _pool.size() + _peakCapacity - _size; + } + +protected: + P activateObject(P pObject) + { + try + { + _factory.activateObject(pObject); + pObject->updateLastUsed(); + } + catch (...) + { + _factory.destroyObject(pObject); + throw; + } + return pObject; + } + +private: + ObjectPool(); + ObjectPool(const ObjectPool&); + ObjectPool& operator = (const ObjectPool&); + + F _factory; + std::size_t _capacity; + std::size_t _peakCapacity; + std::size_t _size; + std::vector

_pool; + mutable Poco::FastMutex _mutex; +}; + +} // namespace Poco + namespace MQ { +typedef Poco::TimedObject TimedQueueManager; -class QueueManagerFactory : public Poco::PoolableObjectFactory +class QueueManagerFactory : public Poco::PoolableObjectFactory { public: QueueManagerFactory(const std::string& qmgrName); @@ -40,9 +237,9 @@ class QueueManagerFactory : public Poco::PoolableObjectFactory +template class PoolGuard { public: + + typedef Poco::SharedPtr > Ptr; + PoolGuard(Poco::SharedPtr pool) : _pool(pool), _object(pool->borrowObject()) { } @@ -65,7 +265,7 @@ class PoolGuard if ( ! _object.isNull() ) _pool->returnObject(_object); } - Poco::SharedPtr getObject() const + PObject& getObject() { return _object; } @@ -76,9 +276,17 @@ class PoolGuard Poco::SharedPtr _pool; - Poco::SharedPtr _object; + PObject _object; }; } // Namespace MQ +namespace MQ { +namespace Web { + +typedef Poco::ObjectPool QueueManagerPool; +typedef PoolGuard QueueManagerPoolGuard; + +}} // namespace MQ::Web + #endif // _MQ_QueueManagerPool_h diff --git a/MQ/src/CommandServer.cpp b/MQ/src/CommandServer.cpp index b8d2835..e40252d 100644 --- a/MQ/src/CommandServer.cpp +++ b/MQ/src/CommandServer.cpp @@ -21,10 +21,10 @@ #include -#include "MQ/Queue.h" +#include "MQ/CommandServer.h" #include "MQ/QueueManager.h" +#include "MQ/Queue.h" #include "MQ/MQException.h" -#include "MQ/CommandServer.h" #include "MQ/Message.h" #include "MQ/PCF.h" @@ -36,9 +36,9 @@ namespace MQ { -CommandServer::CommandServer(QueueManager::Ptr qmgr, const std::string& modelQueue) +CommandServer::CommandServer(QueueManager& qmgr, const std::string& modelQueue) : _qmgr(qmgr) - , _commandQ(qmgr, qmgr->commandQueue()) + , _commandQ(qmgr, qmgr.commandQueue()) , _replyQ(qmgr, modelQueue) { _commandQ.open(MQOO_OUTPUT); @@ -48,7 +48,7 @@ CommandServer::CommandServer(QueueManager::Ptr qmgr, const std::string& modelQue PCF::Ptr CommandServer::createCommand(MQLONG command) const { - return new PCF(command, _qmgr->zos()); + return new PCF(command, _qmgr.zos()); } // Throws MQException @@ -63,7 +63,7 @@ void CommandServer::sendCommand(PCF::Ptr& command, PCF::Vector& response) PCF::Ptr msgResponse; do { - msgResponse = new PCF(_qmgr->zos()); + msgResponse = new PCF(_qmgr.zos()); msgResponse->setCorrelationId(*command->getMessageId()); msgResponse->buffer().resize(REPLY_MESSAGE_LEN, false); diff --git a/MQ/src/Queue.cpp b/MQ/src/Queue.cpp index f428fb6..4ee8226 100644 --- a/MQ/src/Queue.cpp +++ b/MQ/src/Queue.cpp @@ -33,7 +33,7 @@ namespace MQ MQOD Queue::_initialOD = { MQOD_DEFAULT }; -Queue::Queue(Poco::SharedPtr qmgr, const std::string& name) +Queue::Queue(QueueManager& qmgr, const std::string& name) : _qmgr(qmgr) , _handle(0) , _od(_initialOD) @@ -60,7 +60,7 @@ Queue::~Queue() void Queue::open(long options) { MQ::MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); - _handle = mqSystem.functions().open(_qmgr->_handle, &_od, options); + _handle = mqSystem.functions().open(_qmgr.handle(), &_od, options); } void Queue::close() @@ -68,7 +68,7 @@ void Queue::close() if ( _handle != 0 ) { MQ::MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); - mqSystem.functions().close(_qmgr->_handle, &_handle, MQCO_NONE); + mqSystem.functions().close(_qmgr.handle(), &_handle, MQCO_NONE); } } @@ -82,7 +82,7 @@ void Queue::put(Message& msg, MQLONG options) MQ::MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); try { - mqSystem.functions().put(_qmgr->_handle, _handle, msg.md(), &pmo, size, size > 0 ? &msg.buffer()[0] : NULL); + mqSystem.functions().put(_qmgr.handle(), _handle, msg.md(), &pmo, size, size > 0 ? &msg.buffer()[0] : NULL); } catch(MQException& mqe) { @@ -122,7 +122,7 @@ void Queue::get(Message& msg, MQLONG options, long wait) MQ::MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); try { - mqSystem.functions().get(_qmgr->_handle, _handle, msg.md(), &gmo, size, size > 0 ? &(msg.buffer()[0]) : NULL, &msg._dataLength); + mqSystem.functions().get(_qmgr.handle(), _handle, msg.md(), &gmo, size, size > 0 ? &(msg.buffer()[0]) : NULL, &msg._dataLength); } catch(MQException& mqe) { @@ -136,7 +136,7 @@ void Queue::inquire(const std::vector& intSelectors, const std::map(); try { - mqSystem.functions().inq(_qmgr->_handle, _handle, intSelectors, charSelectors, intResult, charResult); + mqSystem.functions().inq(_qmgr.handle(), _handle, intSelectors, charSelectors, intResult, charResult); } catch(MQException& mqe) { diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index 3e73ccd..e3ffb43 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -45,22 +45,22 @@ QueueManagerFactory::~QueueManagerFactory() { } -QueueManager::Ptr QueueManagerFactory::createObject() +TimedQueueManager::Ptr QueueManagerFactory::createObject() { - return new QueueManager(_qmgrName); + return new TimedQueueManager(new QueueManager(_qmgrName)); } -void QueueManagerFactory::activateObject(QueueManager::Ptr qmgr) +void QueueManagerFactory::activateObject(TimedQueueManager::Ptr qmgr) { - if ( !qmgr->connected() ) + if ( !qmgr->getObject()->connected() ) { if ( _connectionInformation.size() == 0 ) { - qmgr->connect(); + qmgr->getObject()->connect(); } else { - qmgr->connect(_connectionInformation); + qmgr->getObject()->connect(_connectionInformation); } } } diff --git a/MQWeb/include/MQ/Web/MQController.h b/MQWeb/include/MQ/Web/MQController.h index fa5ef3a..2012ff5 100644 --- a/MQWeb/include/MQ/Web/MQController.h +++ b/MQWeb/include/MQ/Web/MQController.h @@ -78,10 +78,7 @@ class MQController : public Controller private: - Poco::SharedPtr _qmgrPoolGuard; - - - Poco::SharedPtr _qmgr; + QueueManagerPoolGuard::Ptr _qmgrPoolGuard; CommandServer::Ptr _commandServer; @@ -99,7 +96,7 @@ class MQController : public Controller inline QueueManager::Ptr MQController::qmgr() { - return _qmgr; + return _qmgrPoolGuard->getObject()->getObject(); } diff --git a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h index 7fd4e90..a27fe42 100644 --- a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h +++ b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h @@ -29,9 +29,6 @@ namespace MQ { namespace Web { -typedef Poco::ObjectPool QueueManagerPool; -typedef PoolGuard QueueManagerPoolGuard; - class QueueManagerPoolCache /// This class implements a cache for queuemanager pools { @@ -43,7 +40,7 @@ class QueueManagerPoolCache virtual ~QueueManagerPoolCache(); /// Destructor. - Poco::SharedPtr getQueueManager(const std::string& qmgrName); + Poco::SharedPtr getQueueManagerPool(const std::string& qmgrName); private: diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index ac9b7d6..1771b97 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -80,14 +80,18 @@ void MQController::beforeAction() } } - _qmgrPoolGuard = _cache.getQueueManager(qmgrName); - _qmgr = _qmgrPoolGuard->getObject(); + Poco::SharedPtr qmgrPool = _cache.getQueueManagerPool(qmgrName); + if ( qmgrPool.isNull() ) + { + //TODO: out of memory ??? + } + _qmgrPoolGuard = new QueueManagerPoolGuard(qmgrPool); std::string qmgrConfig = "mq.web.qmgr." + qmgrName; - _mqwebData->set("qmgr", _qmgr->name()); - _mqwebData->set("zos", _qmgr->zos()); - _mqwebData->set("qmgrId", _qmgr->id()); + _mqwebData->set("qmgr", qmgr()->name()); + _mqwebData->set("zos", qmgr()->zos()); + _mqwebData->set("qmgrId", qmgr()->id()); std::string qmgrConfigReplyQ = qmgrConfig + ".reply"; @@ -101,9 +105,13 @@ void MQController::beforeAction() replyQ = config.getString("mq.web.reply", "SYSTEM.DEFAULT.MODEL.QUEUE"); } _mqwebData->set("replyq", replyQ); - _mqwebData->set("cmdq", _qmgr->commandQueue()); + _mqwebData->set("cmdq", qmgr()->commandQueue()); - _commandServer = new CommandServer(_qmgr, replyQ); + _commandServer = qmgr()->commandServer(); + if ( _commandServer.isNull() ) + { + _commandServer = qmgr()->createCommandServer(replyQ); + } } diff --git a/MQWeb/src/MessageController.cpp b/MQWeb/src/MessageController.cpp index 8bf4f94..5e0da2f 100644 --- a/MQWeb/src/MessageController.cpp +++ b/MQWeb/src/MessageController.cpp @@ -217,7 +217,7 @@ void MessageController::browse() Poco::JSON::Array::Ptr jsonMessages = new Poco::JSON::Array(); - Queue q(qmgr(), queueName); + Queue q(*qmgr(), queueName); q.open(MQOO_BROWSE); int count = 0; @@ -302,7 +302,7 @@ void MessageController::dump() return; } - Queue q(qmgr(), queueName); + Queue q(*qmgr(), queueName); q.open(MQOO_BROWSE); try @@ -462,7 +462,7 @@ void MessageController::event() } std::string queueName = parameters[1]; - Queue q(qmgr(), queueName); + Queue q(*qmgr().get(), queueName); q.open(MQOO_INQUIRE | MQOO_BROWSE | MQBND_BIND_ON_OPEN); std::vector intSelectors; diff --git a/MQWeb/src/QueueManagerPoolCache.cpp b/MQWeb/src/QueueManagerPoolCache.cpp index 74ff36b..f719e33 100644 --- a/MQWeb/src/QueueManagerPoolCache.cpp +++ b/MQWeb/src/QueueManagerPoolCache.cpp @@ -36,7 +36,7 @@ QueueManagerPoolCache::~QueueManagerPoolCache() { } -Poco::SharedPtr QueueManagerPoolCache::getQueueManager(const std::string& qmgrName) +Poco::SharedPtr QueueManagerPoolCache::getQueueManagerPool(const std::string& qmgrName) { Poco::SharedPtr pool = _cache.get(qmgrName); if ( pool.isNull() ) @@ -46,14 +46,10 @@ Poco::SharedPtr QueueManagerPoolCache::getQueueManager(co if ( pool.isNull() ) { pool = createPool(qmgrName); - if ( pool.isNull() ) - { - //TODO: throw exception ... - } } } - return new QueueManagerPoolGuard(pool); + return pool; } Poco::SharedPtr QueueManagerPoolCache::createPool(const std::string& qmgrName) From a0a60a566efc1f2e60412fc9260f90021f75b9a3 Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 30 Oct 2014 19:06:00 +0100 Subject: [PATCH 127/143] Working on pooling (doesn't compile yet) --- MQ/include/MQ/QueueManagerPool.h | 239 ++++++++++--------------------- MQ/src/QueueManagerPool.cpp | 102 ++++++++++++- 2 files changed, 169 insertions(+), 172 deletions(-) diff --git a/MQ/include/MQ/QueueManagerPool.h b/MQ/include/MQ/QueueManagerPool.h index 0964945..82b6e16 100644 --- a/MQ/include/MQ/QueueManagerPool.h +++ b/MQ/include/MQ/QueueManagerPool.h @@ -21,20 +21,17 @@ #ifndef _MQ_QueueManagerPool_h #define _MQ_QueueManagerPool_h -#include "Poco/ObjectPool.h" - #include "MQ/QueueManager.h" -namespace Poco { +namespace MQ { template class TimedObject + /// Helper class for storing the last used timestamp { public: - typedef SharedPtr > Ptr; - - TimedObject(const C& object) : _object(object) + TimedObject(Poco::SharedPtr object) : _object(object) { } @@ -42,11 +39,16 @@ class TimedObject { } - C& getObject() + Poco::SharedPtr value() { return _object; } + Poco::Timestamp lastused() + { + return _lastUsed; + } + void updateLastUsed() { _lastUsed.update(); @@ -54,68 +56,52 @@ class TimedObject private: - C _object; + Poco::SharedPtr _object; Poco::Timestamp _lastUsed; }; +typedef TimedObject TimedQueueManager; -template -class ObjectPool, P, F> - /// An ObjectPool manages a pool of objects of a certain class. - /// - /// The number of objects managed by the pool can be restricted. - /// - /// When an object is requested from the pool: - /// - If an object is available from the pool, an object from the pool is - /// removed from the pool, activated (using the factory) and returned. - /// - Otherwise, if the peak capacity of the pool has not yet been reached, - /// a new object is created and activated, using the object factory, and returned. - /// - If the peak capacity has already been reached, null is returned. - /// - /// When an object is returned to the pool: - /// - If the object is valid (checked by calling validateObject() - /// from the object factory), the object is deactivated. If the - /// number of objects in the pool is below the capacity, - /// the object is added to the pool. Otherwise it is destroyed. - /// - If the object is not valid, it is destroyed immediately. +class QueueManagerFactory { public: + QueueManagerFactory(const std::string& qmgrName); - ObjectPool(std::size_t capacity, std::size_t peakCapacity): - /// Creates a new ObjectPool with the given capacity - /// and peak capacity. - /// - /// The PoolableObjectFactory must have a public default constructor. - _capacity(capacity), - _peakCapacity(peakCapacity), - _size(0) - { - poco_assert (capacity <= peakCapacity); - } + QueueManagerFactory(const std::string& qmgrName, const Poco::DynamicStruct& connectionInformation); - ObjectPool(const F& factory, std::size_t capacity, std::size_t peakCapacity): - /// Creates a new ObjectPool with the given PoolableObjectFactory, - /// capacity and peak capacity. The PoolableObjectFactory must have - /// a public copy constructor. - _factory(factory), - _capacity(capacity), - _peakCapacity(peakCapacity), - _size(0) - { - poco_assert (capacity <= peakCapacity); - } + QueueManagerFactory(const QueueManagerFactory& factory); + + virtual ~QueueManagerFactory(); + + QueueManager::Ptr createObject(); + + void activateObject(QueueManager::Ptr qmgr); + + bool validateObject(QueueManager::Ptr pObject); - ~ObjectPool() + void deactivateObject(QueueManager::Ptr pObject); + + void destroyObject(QueueManager::Ptr qmgr); + +private: + + std::string _qmgrName; + + Poco::DynamicStruct _connectionInformation; +}; + +class QueueManagerPool +{ +public: + + QueueManagerPool(Poco::SharedPtr factory, std::size_t capacity, std::size_t peakCapacity); + /// Constructor + + ~QueueManagerPool(); /// Destroys the ObjectPool. - { - for (typename std::vector

::iterator it = _pool.begin(); it != _pool.end(); ++it) - { - _factory.destroyObject(*it); - } - } - P borrowObject() + QueueManager::Ptr borrowObject(); /// Obtains an object from the pool, or creates a new object if /// possible. /// @@ -123,130 +109,57 @@ class ObjectPool, P, F> /// /// If activating the object fails, the object is destroyed and /// the exception is passed on to the caller. - { - Poco::FastMutex::ScopedLock lock(_mutex); - - if (!_pool.empty()) - { - P pObject = _pool.back(); - _pool.pop_back(); - return activateObject(pObject); - } - else if (_size < _peakCapacity) - { - P pObject = _factory.createObject(); - activateObject(pObject); - _size++; - return pObject; - } - else return 0; - } - void returnObject(P pObject) + void returnObject(QueueManager::Ptr pObject); /// Returns an object to the pool. - { - Poco::FastMutex::ScopedLock lock(_mutex); - - if (_factory.validateObject(pObject)) - { - _factory.deactivateObject(pObject); - if (_pool.size() < _capacity) - { - _pool.push_back(pObject); - } - else - { - _factory.destroyObject(pObject); - _size--; - } - } - else - { - _factory.destroyObject(pObject); - } - } - std::size_t capacity() const - { - return _capacity; - } + std::size_t capacity() const; - std::size_t peakCapacity() const - { - return _peakCapacity; - } - - std::size_t size() const - { - Poco::FastMutex::ScopedLock lock(_mutex); - - return _size; - } + std::size_t peakCapacity() const; - std::size_t available() const - { - Poco::FastMutex::ScopedLock lock(_mutex); + std::size_t size() const; - return _pool.size() + _peakCapacity - _size; - } + std::size_t available() const; protected: - P activateObject(P pObject) - { - try - { - _factory.activateObject(pObject); - pObject->updateLastUsed(); - } - catch (...) - { - _factory.destroyObject(pObject); - throw; - } - return pObject; - } + QueueManager::Ptr activateObject(QueueManager::Ptr pObject); private: - ObjectPool(); - ObjectPool(const ObjectPool&); - ObjectPool& operator = (const ObjectPool&); + QueueManagerPool(); + QueueManagerPool(const QueueManagerPool&); + QueueManagerPool& operator = (const QueueManagerPool&); - F _factory; + Poco::SharedPtr _factory; std::size_t _capacity; std::size_t _peakCapacity; std::size_t _size; - std::vector

_pool; + std::vector > _pool; mutable Poco::FastMutex _mutex; }; -} // namespace Poco - - -namespace MQ { - -typedef Poco::TimedObject TimedQueueManager; - -class QueueManagerFactory : public Poco::PoolableObjectFactory +inline std::size_t QueueManagerPool::capacity() const { -public: - QueueManagerFactory(const std::string& qmgrName); + return _capacity; +} - QueueManagerFactory(const std::string& qmgrName, const Poco::DynamicStruct& connectionInformation); - - QueueManagerFactory(const QueueManagerFactory& factory); - - virtual ~QueueManagerFactory(); - - TimedQueueManager::Ptr createObject(); +inline std::size_t QueueManagerPool::peakCapacity() const +{ + return _peakCapacity; +} - void activateObject(TimedQueueManager::Ptr qmgr); +inline std::size_t QueueManagerPool::size() const +{ + Poco::FastMutex::ScopedLock lock(_mutex); -private: + return _size; +} - std::string _qmgrName; +inline std::size_t QueueManagerPool::available() const +{ + Poco::FastMutex::ScopedLock lock(_mutex); - Poco::DynamicStruct _connectionInformation; -}; + return _pool.size() + _peakCapacity - _size; +} template @@ -279,14 +192,8 @@ class PoolGuard PObject _object; }; -} // Namespace MQ - -namespace MQ { -namespace Web { - -typedef Poco::ObjectPool QueueManagerPool; -typedef PoolGuard QueueManagerPoolGuard; +typedef PoolGuard QueueManagerPoolGuard; -}} // namespace MQ::Web +} // namespace MQ #endif // _MQ_QueueManagerPool_h diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index e3ffb43..22a9d86 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -45,24 +45,114 @@ QueueManagerFactory::~QueueManagerFactory() { } -TimedQueueManager::Ptr QueueManagerFactory::createObject() +QueueManager::Ptr QueueManagerFactory::createObject() { - return new TimedQueueManager(new QueueManager(_qmgrName)); + return new QueueManager(_qmgrName); } -void QueueManagerFactory::activateObject(TimedQueueManager::Ptr qmgr) +void QueueManagerFactory::activateObject(QueueManager::Ptr qmgr) { - if ( !qmgr->getObject()->connected() ) + if ( !qmgr->connected() ) { if ( _connectionInformation.size() == 0 ) { - qmgr->getObject()->connect(); + qmgr->connect(); } else { - qmgr->getObject()->connect(_connectionInformation); + qmgr->connect(_connectionInformation); } } } +bool QueueManagerFactory::validateObject(QueueManager::Ptr pObject) +{ + return true; +} + +void QueueManagerFactory::deactivateObject(QueueManager::Ptr pObject) +{ +} + +void QueueManagerFactory::destroyObject(QueueManager::Ptr pObject) +{ +} + +QueueManagerPool::QueueManagerPool(Poco::SharedPtr factory, std::size_t capacity, std::size_t peakCapacity) : + _factory(factory), + _capacity(capacity), + _peakCapacity(peakCapacity), + _size(0) +{ + poco_assert(capacity <= peakCapacity); +} + +QueueManagerPool::~QueueManagerPool() +{ + for (typename std::vector >::iterator it = _pool.begin(); it != _pool.end(); ++it) + { + _factory->destroyObject((*it)->value()->get()); + } +} + +QueueManager::Ptr QueueManagerPool::borrowObject() +{ + Poco::FastMutex::ScopedLock lock(_mutex); + + if (!_pool.empty()) + { + Poco::SharedPtr pObject = _pool.back(); + _pool.pop_back(); + return activateObject(pObject->value()->get()); + } + + if (_size < _peakCapacity) + { + QueueManager::Ptr pObject = _factory->createObject(); + activateObject(pObject); + _size++; + return pObject; + } + + return 0; +} + +void QueueManagerPool::returnObject(QueueManager::Ptr pObject) +{ + Poco::FastMutex::ScopedLock lock(_mutex); + + if (_factory->validateObject(pObject)) + { + _factory->deactivateObject(pObject); + if (_pool.size() < _capacity) + { + Poco::SharedPtr timed = new TimedQueueManager(pObject); + _pool.push_back(timed); + } + else + { + _factory->destroyObject(pObject); + _size--; + } + } + else + { + _factory->destroyObject(pObject); + } +} + +QueueManager::Ptr QueueManagerPool::activateObject(QueueManager::Ptr pObject) +{ + try + { + _factory->activateObject(pObject); + } + catch (...) + { + _factory->destroyObject(pObject); + throw; + } + return pObject; +} + } // Namespace MQ From 7f1c60432e3968758f3b9b924f9aa64d0ffcd9a1 Mon Sep 17 00:00:00 2001 From: fbraem Date: Thu, 30 Oct 2014 22:33:37 +0100 Subject: [PATCH 128/143] Make it compile again ... --- MQ/include/MQ/QueueManagerPool.h | 2 +- MQ/src/QueueManagerPool.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MQ/include/MQ/QueueManagerPool.h b/MQ/include/MQ/QueueManagerPool.h index 82b6e16..b8e36ce 100644 --- a/MQ/include/MQ/QueueManagerPool.h +++ b/MQ/include/MQ/QueueManagerPool.h @@ -61,7 +61,7 @@ class TimedObject Poco::Timestamp _lastUsed; }; -typedef TimedObject TimedQueueManager; +typedef TimedObject TimedQueueManager; class QueueManagerFactory { diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index 22a9d86..4fe474b 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -91,7 +91,7 @@ QueueManagerPool::~QueueManagerPool() { for (typename std::vector >::iterator it = _pool.begin(); it != _pool.end(); ++it) { - _factory->destroyObject((*it)->value()->get()); + _factory->destroyObject((*it)->value()); } } @@ -103,7 +103,7 @@ QueueManager::Ptr QueueManagerPool::borrowObject() { Poco::SharedPtr pObject = _pool.back(); _pool.pop_back(); - return activateObject(pObject->value()->get()); + return activateObject(pObject->value()); } if (_size < _peakCapacity) From 69b25d987666066d81535fe49b2de94308682298 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Fri, 31 Oct 2014 07:14:16 +0100 Subject: [PATCH 129/143] Remove typename --- MQ/src/QueueManagerPool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index 4fe474b..30bc324 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -89,7 +89,7 @@ QueueManagerPool::QueueManagerPool(Poco::SharedPtr factory, QueueManagerPool::~QueueManagerPool() { - for (typename std::vector >::iterator it = _pool.begin(); it != _pool.end(); ++it) + for (std::vector >::iterator it = _pool.begin(); it != _pool.end(); ++it) { _factory->destroyObject((*it)->value()); } From bb4f19d102b96fc6f48f3e9a409662eb18616d28 Mon Sep 17 00:00:00 2001 From: Franky Braem Date: Fri, 31 Oct 2014 08:02:07 +0100 Subject: [PATCH 130/143] Update MQController.h --- MQWeb/include/MQ/Web/MQController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQWeb/include/MQ/Web/MQController.h b/MQWeb/include/MQ/Web/MQController.h index 2012ff5..33a4aa1 100644 --- a/MQWeb/include/MQ/Web/MQController.h +++ b/MQWeb/include/MQ/Web/MQController.h @@ -96,7 +96,7 @@ class MQController : public Controller inline QueueManager::Ptr MQController::qmgr() { - return _qmgrPoolGuard->getObject()->getObject(); + return _qmgrPoolGuard->getObject(); } From 031781633f04b553db75bdd09ebaf994c2c4a6b7 Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 31 Oct 2014 20:30:54 +0100 Subject: [PATCH 131/143] Add rt lib --- MQWeb/premake4.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/MQWeb/premake4.lua b/MQWeb/premake4.lua index 99d74bb..f6bf222 100644 --- a/MQWeb/premake4.lua +++ b/MQWeb/premake4.lua @@ -100,5 +100,6 @@ if ( poco_static ) then links { "pthread" , "dl" + , "rt" } end From 9b615c88787f10ff37022471c58c85ee0a91499b Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 31 Oct 2014 20:31:19 +0100 Subject: [PATCH 132/143] Connection Pooling. Ready to test ... --- MQ/include/MQ/QueueManagerPool.h | 23 ++++++++++++++--- MQ/src/QueueManagerPool.cpp | 27 ++++++++++++++++++-- MQWeb/include/MQ/Web/QueueManagerPoolCache.h | 7 +++-- MQWeb/src/MQController.cpp | 20 ++++++++++----- MQWeb/src/QueueManagerPoolCache.cpp | 17 +++++------- 5 files changed, 68 insertions(+), 26 deletions(-) diff --git a/MQ/include/MQ/QueueManagerPool.h b/MQ/include/MQ/QueueManagerPool.h index b8e36ce..7585069 100644 --- a/MQ/include/MQ/QueueManagerPool.h +++ b/MQ/include/MQ/QueueManagerPool.h @@ -21,6 +21,8 @@ #ifndef _MQ_QueueManagerPool_h #define _MQ_QueueManagerPool_h +#include "Poco/Timer.h" + #include "MQ/QueueManager.h" namespace MQ { @@ -44,7 +46,12 @@ class TimedObject return _object; } - Poco::Timestamp lastused() + int idle() const + { + return (int) (_lastUsed.elapsed() / Poco::Timestamp::resolution()); + } + + Poco::Timestamp lastused() const { return _lastUsed; } @@ -64,6 +71,7 @@ class TimedObject typedef TimedObject TimedQueueManager; class QueueManagerFactory + /// Factory class for creating a queuemanager { public: QueueManagerFactory(const std::string& qmgrName); @@ -95,7 +103,12 @@ class QueueManagerPool { public: - QueueManagerPool(Poco::SharedPtr factory, std::size_t capacity, std::size_t peakCapacity); + typedef Poco::SharedPtr Ptr; + + QueueManagerPool(Poco::SharedPtr factory, + std::size_t capacity, + std::size_t peakCapacity, + int idleTime = 60); /// Constructor ~QueueManagerPool(); @@ -123,6 +136,7 @@ class QueueManagerPool protected: QueueManager::Ptr activateObject(QueueManager::Ptr pObject); + void onJanitorTimer(Poco::Timer&); private: QueueManagerPool(); @@ -135,6 +149,9 @@ class QueueManagerPool std::size_t _size; std::vector > _pool; mutable Poco::FastMutex _mutex; + + int _idleTime; + Poco::Timer _janitorTimer; }; inline std::size_t QueueManagerPool::capacity() const @@ -169,7 +186,7 @@ class PoolGuard typedef Poco::SharedPtr > Ptr; - PoolGuard(Poco::SharedPtr pool) : _pool(pool), _object(pool->borrowObject()) + PoolGuard(Poco::SharedPtr pool, PObject object) : _pool(pool), _object(object) { } diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index 30bc324..949139b 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -78,13 +78,20 @@ void QueueManagerFactory::destroyObject(QueueManager::Ptr pObject) { } -QueueManagerPool::QueueManagerPool(Poco::SharedPtr factory, std::size_t capacity, std::size_t peakCapacity) : +QueueManagerPool::QueueManagerPool(Poco::SharedPtr factory, + std::size_t capacity, + std::size_t peakCapacity, + int idleTime) : _factory(factory), _capacity(capacity), _peakCapacity(peakCapacity), - _size(0) + _size(0), + _idleTime(idleTime), + _janitorTimer(1000 * idleTime, 1000 * idleTime / 4) { poco_assert(capacity <= peakCapacity); + Poco::TimerCallback callback(*this, &QueueManagerPool::onJanitorTimer); + _janitorTimer.start(callback); } QueueManagerPool::~QueueManagerPool() @@ -155,4 +162,20 @@ QueueManager::Ptr QueueManagerPool::activateObject(QueueManager::Ptr pObject) return pObject; } +void QueueManagerPool::onJanitorTimer(Poco::Timer&) +{ + Poco::FastMutex::ScopedLock lock(_mutex); + + std::vector >::iterator it = _pool.begin(); + while(it != _pool.end()) + { + if ( (*it)->idle() > _idleTime ) + { + _factory->destroyObject((*it)->value()); + it = _pool.erase(it); + } + else ++it; + } +} + } // Namespace MQ diff --git a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h index a27fe42..a0fd838 100644 --- a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h +++ b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h @@ -21,11 +21,10 @@ #ifndef _MQ_QueueManagerPoolCache_h #define _MQ_QueueManagerPoolCache_h -#include "Poco/Dynamic/Struct.h" #include "Poco/ExpireCache.h" +#include "Poco/Dynamic/Struct.h" #include "MQ/QueueManagerPool.h" - namespace MQ { namespace Web { @@ -40,11 +39,11 @@ class QueueManagerPoolCache virtual ~QueueManagerPoolCache(); /// Destructor. - Poco::SharedPtr getQueueManagerPool(const std::string& qmgrName); + QueueManagerPool::Ptr getQueueManagerPool(const std::string& qmgrName); private: - Poco::SharedPtr createPool(const std::string& qmgrName); + QueueManagerPool::Ptr createPool(const std::string& qmgrName); Poco::ExpireCache _cache; diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index 1771b97..8332d48 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -85,13 +85,19 @@ void MQController::beforeAction() { //TODO: out of memory ??? } - _qmgrPoolGuard = new QueueManagerPoolGuard(qmgrPool); + + QueueManager::Ptr qmgr = qmgrPool->borrowObject(); + if ( qmgr.isNull() ) + { + //TODO: out of memory??? + } + _qmgrPoolGuard = new QueueManagerPoolGuard(qmgrPool, qmgr); std::string qmgrConfig = "mq.web.qmgr." + qmgrName; - _mqwebData->set("qmgr", qmgr()->name()); - _mqwebData->set("zos", qmgr()->zos()); - _mqwebData->set("qmgrId", qmgr()->id()); + _mqwebData->set("qmgr", qmgr->name()); + _mqwebData->set("zos", qmgr->zos()); + _mqwebData->set("qmgrId", qmgr->id()); std::string qmgrConfigReplyQ = qmgrConfig + ".reply"; @@ -105,12 +111,12 @@ void MQController::beforeAction() replyQ = config.getString("mq.web.reply", "SYSTEM.DEFAULT.MODEL.QUEUE"); } _mqwebData->set("replyq", replyQ); - _mqwebData->set("cmdq", qmgr()->commandQueue()); + _mqwebData->set("cmdq", qmgr->commandQueue()); - _commandServer = qmgr()->commandServer(); + _commandServer = qmgr->commandServer(); if ( _commandServer.isNull() ) { - _commandServer = qmgr()->createCommandServer(replyQ); + _commandServer = qmgr->createCommandServer(replyQ); } } diff --git a/MQWeb/src/QueueManagerPoolCache.cpp b/MQWeb/src/QueueManagerPoolCache.cpp index f719e33..f83a410 100644 --- a/MQWeb/src/QueueManagerPoolCache.cpp +++ b/MQWeb/src/QueueManagerPoolCache.cpp @@ -36,9 +36,9 @@ QueueManagerPoolCache::~QueueManagerPoolCache() { } -Poco::SharedPtr QueueManagerPoolCache::getQueueManagerPool(const std::string& qmgrName) +QueueManagerPool::Ptr QueueManagerPoolCache::getQueueManagerPool(const std::string& qmgrName) { - Poco::SharedPtr pool = _cache.get(qmgrName); + QueueManagerPool::Ptr pool = _cache.get(qmgrName); if ( pool.isNull() ) { Poco::Mutex::ScopedLock lock(_mutex); @@ -52,9 +52,9 @@ Poco::SharedPtr QueueManagerPoolCache::getQueueManagerPool(con return pool; } -Poco::SharedPtr QueueManagerPoolCache::createPool(const std::string& qmgrName) +QueueManagerPool::Ptr QueueManagerPoolCache::createPool(const std::string& qmgrName) { - Poco::SharedPtr pool; + QueueManagerPool::Ptr pool; MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); Poco::Util::LayeredConfiguration& config = Poco::Util::Application::instance().config(); @@ -98,19 +98,16 @@ Poco::SharedPtr QueueManagerPoolCache::createPool(const std::s } } - QueueManagerFactory qmgrFactory(qmgrName, connectionInformation); - pool = new QueueManagerPool(qmgrFactory, 10, 20); + pool = new QueueManagerPool(new QueueManagerFactory(qmgrName, connectionInformation), 10, 20); } else { - QueueManagerFactory qmgrFactory(qmgrName); - pool = new QueueManagerPool(qmgrFactory, 10, 20); + pool = new QueueManagerPool(new QueueManagerFactory(qmgrName), 10, 20); } } else { - QueueManagerFactory qmgrFactory(qmgrName); - pool = new QueueManagerPool(qmgrFactory, 10, 20); + pool = new QueueManagerPool(new QueueManagerFactory(qmgrName), 10, 20); } _cache.add(qmgrName, pool); From 17676d5f6b9e7dfc99f2e101959a0db69c0f091c Mon Sep 17 00:00:00 2001 From: fbraem Date: Fri, 31 Oct 2014 22:10:52 +0100 Subject: [PATCH 133/143] Minor updates --- MQ/src/QueueManagerPool.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index 949139b..6b1b737 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -67,7 +67,7 @@ void QueueManagerFactory::activateObject(QueueManager::Ptr qmgr) bool QueueManagerFactory::validateObject(QueueManager::Ptr pObject) { - return true; + return pObject->connected(); } void QueueManagerFactory::deactivateObject(QueueManager::Ptr pObject) @@ -76,6 +76,7 @@ void QueueManagerFactory::deactivateObject(QueueManager::Ptr pObject) void QueueManagerFactory::destroyObject(QueueManager::Ptr pObject) { + pObject->disconnect(); } QueueManagerPool::QueueManagerPool(Poco::SharedPtr factory, @@ -172,6 +173,7 @@ void QueueManagerPool::onJanitorTimer(Poco::Timer&) if ( (*it)->idle() > _idleTime ) { _factory->destroyObject((*it)->value()); + _size--; it = _pool.erase(it); } else ++it; From 5e76232b10b90ef0bb0525463aba8c9103849e3c Mon Sep 17 00:00:00 2001 From: fbraem Date: Sat, 1 Nov 2014 20:30:36 +0100 Subject: [PATCH 134/143] Options in connect must be MQCNO_HANDLE_SHARE_BLOCK --- MQ/src/QueueManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MQ/src/QueueManager.cpp b/MQ/src/QueueManager.cpp index 64d3dd0..315e43b 100644 --- a/MQ/src/QueueManager.cpp +++ b/MQ/src/QueueManager.cpp @@ -58,7 +58,7 @@ void QueueManager::connect() { MQCNO cno = { MQCNO_DEFAULT }; cno.Version = MQCNO_VERSION_2; - cno.Options = MQCNO_HANDLE_SHARE_NONE; + cno.Options = MQCNO_HANDLE_SHARE_BLOCK; MQ::MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); _handle = mqSystem.functions().connx(_name, &cno); From 90016f64c54b15a6ed12102c6ffcc5d1706e0002 Mon Sep 17 00:00:00 2001 From: fbraem Date: Sat, 1 Nov 2014 20:31:10 +0100 Subject: [PATCH 135/143] Don't throw an exception in destroyObject --- MQ/src/QueueManagerPool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp index 6b1b737..bffae86 100644 --- a/MQ/src/QueueManagerPool.cpp +++ b/MQ/src/QueueManagerPool.cpp @@ -76,7 +76,13 @@ void QueueManagerFactory::deactivateObject(QueueManager::Ptr pObject) void QueueManagerFactory::destroyObject(QueueManager::Ptr pObject) { - pObject->disconnect(); + try + { + pObject->disconnect(); + } + catch(...) + { + } } QueueManagerPool::QueueManagerPool(Poco::SharedPtr factory, From dff49ff982091acf6011c44de23b6f854cc1d05e Mon Sep 17 00:00:00 2001 From: fbraem Date: Sun, 2 Nov 2014 22:36:36 +0100 Subject: [PATCH 136/143] Use a pointer to the commandserver to control the scope of it. Make one instance of QueueManagerPoolCache and clear it before the application stops. --- MQ/include/MQ/QueueManager.h | 10 +++++----- MQ/src/QueueManager.cpp | 10 +++++++++- MQWeb/include/MQ/Web/Application.h | 8 ++++++++ MQWeb/include/MQ/Web/MQController.h | 9 +++------ MQWeb/include/MQ/Web/QueueManagerPoolCache.h | 19 +++++++++++++++++++ MQWeb/src/Application.cpp | 2 ++ MQWeb/src/MQController.cpp | 7 +++---- MQWeb/src/QueueManagerPoolCache.cpp | 14 ++++++++++++++ 8 files changed, 63 insertions(+), 16 deletions(-) diff --git a/MQ/include/MQ/QueueManager.h b/MQ/include/MQ/QueueManager.h index caa7c74..85630dd 100644 --- a/MQ/include/MQ/QueueManager.h +++ b/MQ/include/MQ/QueueManager.h @@ -47,7 +47,7 @@ class QueueManager virtual ~QueueManager(); /// Destructor. Disconnects the queuemanager when it is still connected. - Poco::SharedPtr commandServer(); + CommandServer* commandServer(); /// Returns the command server for this queuemanager. A command server /// must be created first with createCommandServer. @@ -73,7 +73,7 @@ class QueueManager bool connected() const; /// Returns true when the queuemanager is connected. - Poco::SharedPtr createCommandServer(const std::string& replyQ); + CommandServer* createCommandServer(const std::string& replyQ); /// Create a command server. Once created, you can use commandServer to /// get the associated command server. Can throw an MQException. @@ -110,7 +110,7 @@ class QueueManager MQLONG _applicationType; - Poco::SharedPtr _commandServer; + CommandServer* _commandServer; void inquireQmgrAttrs(); @@ -150,12 +150,12 @@ inline bool QueueManager::zos() const return _applicationType == MQPL_ZOS; } -inline Poco::SharedPtr QueueManager::commandServer() +inline CommandServer* QueueManager::commandServer() { return _commandServer; } -inline Poco::SharedPtr QueueManager::createCommandServer(const std::string& replyQ) +inline CommandServer* QueueManager::createCommandServer(const std::string& replyQ) { _commandServer = new CommandServer(*this, replyQ); return _commandServer; diff --git a/MQ/src/QueueManager.cpp b/MQ/src/QueueManager.cpp index 315e43b..dc7b0f8 100644 --- a/MQ/src/QueueManager.cpp +++ b/MQ/src/QueueManager.cpp @@ -33,7 +33,8 @@ namespace MQ QueueManager::QueueManager(const std::string& name) : _handle(0), _name(name), - _applicationType(0) + _applicationType(0), + _commandServer(NULL) { } @@ -255,6 +256,13 @@ void QueueManager::disconnect() { if ( _handle != 0 ) { + // Release the command server now, so queues are closed correctly. + if ( _commandServer != NULL ) + { + delete _commandServer; + _commandServer = NULL; + } + MQ::MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); mqSystem.functions().disc(&_handle); _handle = 0; diff --git a/MQWeb/include/MQ/Web/Application.h b/MQWeb/include/MQ/Web/Application.h index d832dd0..8f9e470 100644 --- a/MQWeb/include/MQ/Web/Application.h +++ b/MQWeb/include/MQ/Web/Application.h @@ -29,6 +29,8 @@ #include "Poco/JSON/TemplateCache.h" +#include "MQ/Web/QueueManagerPoolCache.h" + class MQWebApplication : public Poco::Util::ServerApplication /// The MQWeb server application { @@ -65,6 +67,12 @@ class MQWebApplication : public Poco::Util::ServerApplication Poco::JSON::TemplateCache _cache; + /// Only one TemplaceCache object is allowed. The best place to define it + /// is here. + + MQ::Web::QueueManagerPoolCache _qmgrPoolCache; + /// Only one QueueManagerPoolCache object is allowed. The best place to + /// define it is here. }; #endif // _MQWeb_Application_H diff --git a/MQWeb/include/MQ/Web/MQController.h b/MQWeb/include/MQ/Web/MQController.h index 33a4aa1..23b7340 100644 --- a/MQWeb/include/MQ/Web/MQController.h +++ b/MQWeb/include/MQ/Web/MQController.h @@ -47,7 +47,7 @@ class MQController : public Controller QueueManager::Ptr qmgr(); /// Returns the associated queuemanager - CommandServer::Ptr commandServer(); + CommandServer* commandServer(); /// Returns the associated command server void handleException(const MQException& mqe); @@ -81,16 +81,13 @@ class MQController : public Controller QueueManagerPoolGuard::Ptr _qmgrPoolGuard; - CommandServer::Ptr _commandServer; + CommandServer* _commandServer; Poco::JSON::Object::Ptr _mqwebData; Poco::Stopwatch _stopwatch; - - - static QueueManagerPoolCache _cache; }; @@ -100,7 +97,7 @@ inline QueueManager::Ptr MQController::qmgr() } -inline CommandServer::Ptr MQController::commandServer() +inline CommandServer* MQController::commandServer() { return _commandServer; } diff --git a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h index a0fd838..cc27df0 100644 --- a/MQWeb/include/MQ/Web/QueueManagerPoolCache.h +++ b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h @@ -30,6 +30,9 @@ namespace Web { class QueueManagerPoolCache /// This class implements a cache for queuemanager pools + /// Create only one instance of this class. + /// Make it a private member of the Application class for example + /// and use the static instance() method to get this instance. { public: @@ -39,17 +42,33 @@ class QueueManagerPoolCache virtual ~QueueManagerPoolCache(); /// Destructor. + void clear(); + /// Clear the cache + QueueManagerPool::Ptr getQueueManagerPool(const std::string& qmgrName); + /// Get a QueueManagerPool from the cache + + static QueueManagerPoolCache* instance(); + /// Returns the only instance of this class private: QueueManagerPool::Ptr createPool(const std::string& qmgrName); + void setup(); + Poco::ExpireCache _cache; Poco::Mutex _mutex; + + static QueueManagerPoolCache* _instance; }; +inline QueueManagerPoolCache* QueueManagerPoolCache::instance() +{ + return _instance; +} + }} // Namespace MQ::Web #endif // _MQ_QueueManagerPoolCache_h diff --git a/MQWeb/src/Application.cpp b/MQWeb/src/Application.cpp index 4243a59..3286c8d 100644 --- a/MQWeb/src/Application.cpp +++ b/MQWeb/src/Application.cpp @@ -211,6 +211,8 @@ int MQWebApplication::main(const std::vector& args) // Stop the HTTPServer srv.stop(); + _qmgrPoolCache.clear(); + return Application::EXIT_OK; } diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index 8332d48..120e491 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -33,9 +33,8 @@ namespace MQ { namespace Web { -QueueManagerPoolCache MQController::_cache; -MQController::MQController() : Controller(), _mqwebData(new Poco::JSON::Object()) +MQController::MQController() : Controller(), _mqwebData(new Poco::JSON::Object()), _commandServer(NULL) { set("mqweb", _mqwebData); } @@ -80,7 +79,7 @@ void MQController::beforeAction() } } - Poco::SharedPtr qmgrPool = _cache.getQueueManagerPool(qmgrName); + Poco::SharedPtr qmgrPool = QueueManagerPoolCache::instance()->getQueueManagerPool(qmgrName); if ( qmgrPool.isNull() ) { //TODO: out of memory ??? @@ -114,7 +113,7 @@ void MQController::beforeAction() _mqwebData->set("cmdq", qmgr->commandQueue()); _commandServer = qmgr->commandServer(); - if ( _commandServer.isNull() ) + if ( _commandServer == NULL ) { _commandServer = qmgr->createCommandServer(replyQ); } diff --git a/MQWeb/src/QueueManagerPoolCache.cpp b/MQWeb/src/QueueManagerPoolCache.cpp index f83a410..7de7709 100644 --- a/MQWeb/src/QueueManagerPoolCache.cpp +++ b/MQWeb/src/QueueManagerPoolCache.cpp @@ -27,13 +27,22 @@ namespace MQ { namespace Web { +QueueManagerPoolCache* QueueManagerPoolCache::_instance = NULL; QueueManagerPoolCache::QueueManagerPoolCache() { + setup(); } QueueManagerPoolCache::~QueueManagerPoolCache() { + _instance = NULL; +} + +void QueueManagerPoolCache::setup() +{ + poco_assert(_instance == NULL); + _instance = this; } QueueManagerPool::Ptr QueueManagerPoolCache::getQueueManagerPool(const std::string& qmgrName) @@ -52,6 +61,11 @@ QueueManagerPool::Ptr QueueManagerPoolCache::getQueueManagerPool(const std::stri return pool; } +void QueueManagerPoolCache::clear() +{ + _cache.clear(); +} + QueueManagerPool::Ptr QueueManagerPoolCache::createPool(const std::string& qmgrName) { QueueManagerPool::Ptr pool; From 06c4d196d1f2cd4e26add00e8688b2411ef6b5a7 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 3 Nov 2014 18:18:50 +0100 Subject: [PATCH 137/143] Remove typedef for SmartPtr --- MQ/include/MQ/CommandServer.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/MQ/include/MQ/CommandServer.h b/MQ/include/MQ/CommandServer.h index aba01a0..c76fed7 100644 --- a/MQ/include/MQ/CommandServer.h +++ b/MQ/include/MQ/CommandServer.h @@ -45,8 +45,6 @@ class CommandServer /// Sends the command to the queuemanager. The response is returned /// as a vector of PCF objects. Can throw a MQException. - typedef Poco::SharedPtr Ptr; - private: CommandServer(QueueManager& qmgr, const std::string& modelQueue); /// Constructor. From 9dc4f8774c7458be8343cd37d9c788ee1fdb69cc Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 3 Nov 2014 18:19:37 +0100 Subject: [PATCH 138/143] Add some comments about owning the commandserver instance --- MQ/include/MQ/QueueManager.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MQ/include/MQ/QueueManager.h b/MQ/include/MQ/QueueManager.h index 85630dd..cf045fd 100644 --- a/MQ/include/MQ/QueueManager.h +++ b/MQ/include/MQ/QueueManager.h @@ -75,10 +75,14 @@ class QueueManager CommandServer* createCommandServer(const std::string& replyQ); /// Create a command server. Once created, you can use commandServer to - /// get the associated command server. Can throw an MQException. + /// get the associated command server. Can throw an MQException. The + /// QueueManager instance is responsible for the CommandServer object + /// and will destroy it when the queuemanager is disconnected. void disconnect(); /// Disconnects from the queuemanager. Can throw an MQException. + /// When a CommandServer object is owned by this queuemanager, it will + /// be destroyed. std::string name() const; /// Returns the name of the queuemanager. The name is always inquired From a546ebbed7d5184606cea6bc99ce0db132012c4e Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 3 Nov 2014 19:37:42 +0100 Subject: [PATCH 139/143] Use config only when CommandServer is not yet created --- MQWeb/src/MQController.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index 120e491..8e1811f 100644 --- a/MQWeb/src/MQController.cpp +++ b/MQWeb/src/MQController.cpp @@ -92,31 +92,32 @@ void MQController::beforeAction() } _qmgrPoolGuard = new QueueManagerPoolGuard(qmgrPool, qmgr); - std::string qmgrConfig = "mq.web.qmgr." + qmgrName; - _mqwebData->set("qmgr", qmgr->name()); _mqwebData->set("zos", qmgr->zos()); _mqwebData->set("qmgrId", qmgr->id()); - std::string qmgrConfigReplyQ = qmgrConfig + ".reply"; - - std::string replyQ; - if ( config.has(qmgrConfigReplyQ) ) - { - replyQ = config.getString(qmgrConfigReplyQ); - } - else - { - replyQ = config.getString("mq.web.reply", "SYSTEM.DEFAULT.MODEL.QUEUE"); - } - _mqwebData->set("replyq", replyQ); - _mqwebData->set("cmdq", qmgr->commandQueue()); - _commandServer = qmgr->commandServer(); if ( _commandServer == NULL ) { + std::string qmgrConfigReplyQ = "mq.web.qmgr." + qmgrName + ".reply"; + + std::string replyQ; + if ( config.has(qmgrConfigReplyQ) ) + { + replyQ = config.getString(qmgrConfigReplyQ); + } + else + { + replyQ = config.getString("mq.web.reply", "SYSTEM.DEFAULT.MODEL.QUEUE"); + } _commandServer = qmgr->createCommandServer(replyQ); } + + if ( _commandServer != NULL ) + { + _mqwebData->set("replyq", _commandServer->replyQName()); + _mqwebData->set("cmdq", _commandServer->commandQName()); + } } From dde7320803a7cc50dd775047721806febed393be Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 3 Nov 2014 19:38:04 +0100 Subject: [PATCH 140/143] Add config for capacity, peakcapacity and idle --- MQWeb/src/QueueManagerPoolCache.cpp | 35 ++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/MQWeb/src/QueueManagerPoolCache.cpp b/MQWeb/src/QueueManagerPoolCache.cpp index 7de7709..6ccf693 100644 --- a/MQWeb/src/QueueManagerPoolCache.cpp +++ b/MQWeb/src/QueueManagerPoolCache.cpp @@ -75,6 +75,8 @@ QueueManagerPool::Ptr QueueManagerPoolCache::createPool(const std::string& qmgrN std::string qmgrConfig = "mq.web.qmgr." + qmgrName; + Poco::SharedPtr factory; + if ( mqSystem.client() ) { Poco::DynamicStruct connectionInformation; @@ -112,17 +114,44 @@ QueueManagerPool::Ptr QueueManagerPoolCache::createPool(const std::string& qmgrN } } - pool = new QueueManagerPool(new QueueManagerFactory(qmgrName, connectionInformation), 10, 20); + factory = new QueueManagerFactory(qmgrName, connectionInformation); } else { - pool = new QueueManagerPool(new QueueManagerFactory(qmgrName), 10, 20); + factory = new QueueManagerFactory(qmgrName); } } else { - pool = new QueueManagerPool(new QueueManagerFactory(qmgrName), 10, 20); + factory = new QueueManagerFactory(qmgrName); + } + + std::size_t capacity; + std::size_t peakCapacity; + int idle; + + std::string qmgrPoolCapacity = qmgrConfig + ".pool.capacity"; + if ( !config.has(qmgrPoolCapacity) ) + { + qmgrPoolCapacity = "mq.web.pool.capacity"; + } + capacity = config.getInt(qmgrPoolCapacity, 10); + + std::string qmgrPoolPeakCapacity = qmgrConfig + ".pool.peakcapacity"; + if ( !config.has(qmgrPoolPeakCapacity) ) + { + qmgrPoolPeakCapacity = "mq.web.pool.peakcapacity"; + } + peakCapacity = config.getInt(qmgrPoolPeakCapacity, 20); + + std::string qmgrPoolIdle = qmgrConfig + ".pool.idle"; + if ( !config.has(qmgrPoolIdle) ) + { + qmgrPoolIdle = "mq.web.pool.idle"; } + idle = config.getInt(qmgrPoolIdle, 60); + + pool = new QueueManagerPool(factory, capacity, peakCapacity, idle); _cache.add(qmgrName, pool); return pool; From 99fffd107a9075c881337c34b78329097af9b0a8 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 3 Nov 2014 19:38:24 +0100 Subject: [PATCH 141/143] Add methods commandQName and replyQName --- MQ/include/MQ/CommandServer.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MQ/include/MQ/CommandServer.h b/MQ/include/MQ/CommandServer.h index c76fed7..58947ad 100644 --- a/MQ/include/MQ/CommandServer.h +++ b/MQ/include/MQ/CommandServer.h @@ -38,6 +38,9 @@ class CommandServer /// Class for sending PCF commands to a queuemanager { public: + std::string commandQName() const; + /// Returns the name of the command queue. + PCF::Ptr createCommand(MQLONG command) const; /// Returns a shared pointer to a PCF object for the given command. @@ -45,6 +48,9 @@ class CommandServer /// Sends the command to the queuemanager. The response is returned /// as a vector of PCF objects. Can throw a MQException. + std::string replyQName() const; + /// Returns the name of the reply queue. + private: CommandServer(QueueManager& qmgr, const std::string& modelQueue); /// Constructor. @@ -61,6 +67,15 @@ class CommandServer friend class QueueManager; }; +inline std::string CommandServer::commandQName() const +{ + return _commandQ.name(); +} + +inline std::string CommandServer::replyQName() const +{ + return _replyQ.name(); +} } // namespace MQ From 19d35db0337a289279430733e1ee28fc4ead9279 Mon Sep 17 00:00:00 2001 From: fbraem Date: Mon, 3 Nov 2014 20:37:24 +0100 Subject: [PATCH 142/143] Add connection pooling --- ChangeLog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index c5ac1b1..371af2d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -6,6 +6,8 @@ - Add inquire authentication information (authinfo) - Add inquire authority record (authrec) - Support for JSONP + - Allow to run without mq.web.templates / mq.web.static configuration + - Add connection pooling 0.0.10 - queueExcludeSystem/queueExcludeTemp renamed into excludeSystem/excludeTemp From cb56908ed92481d4feaf0ed0e715a8996f556aa3 Mon Sep 17 00:00:00 2001 From: fbraem Date: Tue, 4 Nov 2014 21:44:17 +0100 Subject: [PATCH 143/143] Using Poco 1.5.4 --- poco.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poco.lua b/poco.lua index b438a57..6a60f66 100644 --- a/poco.lua +++ b/poco.lua @@ -12,10 +12,10 @@ poco_dir = "" poco_lib_dir = poco_dir .. "" -- A Linux example: -poco_dir = "/home/bronx/Development/poco" -- where did you extract POCO? -poco_lib_dir = poco_dir .. "/static/lib/Linux/i686" -- where are the libraries? +-- poco_dir = "/home/bronx/Development/poco-1.5.4-all" -- where did you extract POCO? +-- poco_lib_dir = poco_dir .. "/static/lib/Linux/i686" -- where are the libraries? -- A Windows example: ---poco_dir = "c:\\development\\poco-1.5.2-release" +--poco_dir = "c:\\development\\poco-1.5.4-release" --poco_lib_dir = poco_dir .. "\\lib"