diff --git a/ChangeLog.txt b/ChangeLog.txt index eb48784..371af2d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,14 @@ +0.0.11 + - Add inquire connection (conn) + - 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 + - Allow to run without mq.web.templates / mq.web.static configuration + - Add connection pooling + 0.0.10 - queueExcludeSystem/queueExcludeTemp renamed into excludeSystem/excludeTemp - channelExcludeSystem renamed into excludeSystem diff --git a/MQ/include/MQ/CommandServer.h b/MQ/include/MQ/CommandServer.h index 85c074c..58947ad 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,12 +32,14 @@ namespace MQ { +class QueueManager; + class CommandServer /// Class for sending PCF commands to a queuemanager { public: - CommandServer(QueueManager::Ptr qmgr, const std::string& modelQueue); - /// Constructor. + 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. @@ -47,26 +48,33 @@ 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 + std::string replyQName() const; + /// Returns the name of the reply queue. +private: + CommandServer(QueueManager& qmgr, const std::string& modelQueue); + /// Constructor. - typedef Poco::SharedPtr Ptr; + CommandServer(const CommandServer& copy); + CommandServer& operator = (const CommandServer& copy); - -private: - QueueManager::Ptr _qmgr; + QueueManager& _qmgr; Queue _commandQ; Queue _replyQ; + + friend class QueueManager; }; +inline std::string CommandServer::commandQName() const +{ + return _commandQ.name(); +} -inline const QueueManager& CommandServer::qmgr() const +inline std::string CommandServer::replyQName() const { - poco_assert_dbg(!_qmgr.isNull()); // Can't be null - return *_qmgr.get(); + return _replyQ.name(); } } // namespace MQ 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/include/MQ/PCF.h b/MQ/include/MQ/PCF.h index ff630b5..76672e1 100644 --- a/MQ/include/MQ/PCF.h +++ b/MQ/include/MQ/PCF.h @@ -56,9 +56,15 @@ class PCF : public Message void addParameter(MQLONG parameter, MQLONG value); /// Add a numeric parameter. - void addParameterList(MQLONG parameter, MQLONG *values); + void addParameter(MQLONG parameter, BufferPtr buffer); + /// Add a byte string parameter. + + void addParameterList(MQLONG parameter, MQLONG *values, unsigned int count); /// 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. @@ -171,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], values.size()); +} inline int PCF::getCommand() const { 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 d484180..cf045fd 100644 --- a/MQ/include/MQ/QueueManager.h +++ b/MQ/include/MQ/QueueManager.h @@ -29,7 +29,9 @@ #include "Poco/SharedPtr.h" #include "Poco/DateTime.h" -#include "Poco/Util/ConfigurationView.h" +#include "Poco/Dynamic/Struct.h" + +#include "MQ/CommandServer.h" namespace MQ { @@ -39,13 +41,16 @@ class QueueManager public: typedef Poco::SharedPtr Ptr; - QueueManager(const std::string& name = ""); /// Constructor. virtual ~QueueManager(); /// Destructor. Disconnects the queuemanager when it is still connected. + CommandServer* 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. @@ -53,7 +58,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::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 @@ -61,8 +66,23 @@ class QueueManager /// Only use this method when MQ system is loaded in client mode. Can /// throw an MQException. + void connect(const Poco::DynamicStruct& 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. + + 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. 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 @@ -84,6 +104,8 @@ class QueueManager MQHCONN _handle; + MQHCONN handle() const; + std::string _name; std::string _id; @@ -92,6 +114,8 @@ class QueueManager MQLONG _applicationType; + CommandServer* _commandServer; + void inquireQmgrAttrs(); friend class Queue; @@ -115,11 +139,32 @@ inline std::string QueueManager::commandQueue() const return _commandQueue; } +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 CommandServer* QueueManager::commandServer() +{ + return _commandServer; +} + +inline CommandServer* 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 new file mode 100644 index 0000000..7585069 --- /dev/null +++ b/MQ/include/MQ/QueueManagerPool.h @@ -0,0 +1,216 @@ +/* + * 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/Timer.h" + +#include "MQ/QueueManager.h" + +namespace MQ { + +template +class TimedObject + /// Helper class for storing the last used timestamp +{ +public: + + TimedObject(Poco::SharedPtr object) : _object(object) + { + } + + ~TimedObject() + { + } + + Poco::SharedPtr value() + { + return _object; + } + + int idle() const + { + return (int) (_lastUsed.elapsed() / Poco::Timestamp::resolution()); + } + + Poco::Timestamp lastused() const + { + return _lastUsed; + } + + void updateLastUsed() + { + _lastUsed.update(); + } + +private: + + Poco::SharedPtr _object; + + Poco::Timestamp _lastUsed; +}; + +typedef TimedObject TimedQueueManager; + +class QueueManagerFactory + /// Factory class for creating a queuemanager +{ +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); + + bool validateObject(QueueManager::Ptr pObject); + + void deactivateObject(QueueManager::Ptr pObject); + + void destroyObject(QueueManager::Ptr qmgr); + +private: + + std::string _qmgrName; + + Poco::DynamicStruct _connectionInformation; +}; + +class QueueManagerPool +{ +public: + + typedef Poco::SharedPtr Ptr; + + QueueManagerPool(Poco::SharedPtr factory, + std::size_t capacity, + std::size_t peakCapacity, + int idleTime = 60); + /// Constructor + + ~QueueManagerPool(); + /// Destroys the ObjectPool. + + QueueManager::Ptr 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. + + void returnObject(QueueManager::Ptr pObject); + /// Returns an object to the pool. + + std::size_t capacity() const; + + std::size_t peakCapacity() const; + + std::size_t size() const; + + std::size_t available() const; + +protected: + QueueManager::Ptr activateObject(QueueManager::Ptr pObject); + void onJanitorTimer(Poco::Timer&); + +private: + QueueManagerPool(); + QueueManagerPool(const QueueManagerPool&); + QueueManagerPool& operator = (const QueueManagerPool&); + + Poco::SharedPtr _factory; + std::size_t _capacity; + std::size_t _peakCapacity; + std::size_t _size; + std::vector > _pool; + mutable Poco::FastMutex _mutex; + + int _idleTime; + Poco::Timer _janitorTimer; +}; + +inline std::size_t QueueManagerPool::capacity() const +{ + return _capacity; +} + +inline std::size_t QueueManagerPool::peakCapacity() const +{ + return _peakCapacity; +} + +inline std::size_t QueueManagerPool::size() const +{ + Poco::FastMutex::ScopedLock lock(_mutex); + + return _size; +} + +inline std::size_t QueueManagerPool::available() const +{ + Poco::FastMutex::ScopedLock lock(_mutex); + + return _pool.size() + _peakCapacity - _size; +} + + +template +class PoolGuard +{ +public: + + typedef Poco::SharedPtr > Ptr; + + PoolGuard(Poco::SharedPtr pool, PObject object) : _pool(pool), _object(object) + { + } + + ~PoolGuard() + { + if ( ! _object.isNull() ) _pool->returnObject(_object); + } + + PObject& getObject() + { + return _object; + } + +private: + PoolGuard(const PoolGuard&); + PoolGuard& operator= (const PoolGuard&); + + Poco::SharedPtr _pool; + + PObject _object; +}; + +typedef PoolGuard QueueManagerPoolGuard; + +} // namespace MQ + +#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/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/MQ/src/PCF.cpp b/MQ/src/PCF.cpp index 94c9059..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 ) @@ -256,11 +257,24 @@ 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) +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]]; @@ -268,7 +282,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++; } 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/QueueManager.cpp b/MQ/src/QueueManager.cpp index afaded8..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) { } @@ -58,7 +59,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); @@ -70,7 +71,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 +86,32 @@ 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::DynamicStruct& connectionInformation) +{ + if ( connectionInformation.contains("ssl") ) + { + Poco::Dynamic::Var ssl = connectionInformation["ssl"]; + if ( ssl.isStruct() ) + { + connect(connectionInformation["channel"], + connectionInformation["connection"], + 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::DynamicStruct& ssl) { MQCNO cno = { MQCNO_DEFAULT }; @@ -94,32 +120,37 @@ 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") ) + + if ( ssl.contains("cipherspec") ) { - strncpy(cd.SSLCipherSpec, ssl.getString("cipherspec").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; 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) ) + 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 + } } - if ( ssl.has("suiteb") ) + if ( ssl.contains("suiteb") ) { static std::map suiteBTable; if ( suiteBTable.size() == 0 ) @@ -131,8 +162,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(ssl["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 +179,7 @@ void QueueManager::connect(const std::string& channel, const std::string& server } #ifdef MQSCO_VERSION_4 - if ( ssl.has("certificate_validation_policy") ) + if ( ssl.contains("certificate_validation_policy") ) { static std::map certValPolicyTable; if ( certValPolicyTable.size() == 0 ) @@ -160,7 +190,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::string certValPolicy = ssl["certificate_validation_policy"].toString(); std::map::iterator certValPolicyIterator = certValPolicyTable.find(certValPolicy); if ( certValPolicyIterator == certValPolicyTable.end() ) { @@ -172,15 +202,13 @@ void QueueManager::connect(const std::string& channel, const std::string& server } } #endif - if ( ssl.has("ocsp_url") ) + if ( ssl.contains("ocsp_url") ) { - 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, ssl["ocsp_url"].toString().c_str(), MQ_AUTH_INFO_OCSP_URL_LENGTH); /* The MQSCO must point to the MQAIR */ sco.AuthInfoRecCount = 1; @@ -228,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/MQ/src/QueueManagerPool.cpp b/MQ/src/QueueManagerPool.cpp new file mode 100644 index 0000000..bffae86 --- /dev/null +++ b/MQ/src/QueueManagerPool.cpp @@ -0,0 +1,189 @@ +/* + * 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 +{ + +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); + } + } +} + +bool QueueManagerFactory::validateObject(QueueManager::Ptr pObject) +{ + return pObject->connected(); +} + +void QueueManagerFactory::deactivateObject(QueueManager::Ptr pObject) +{ +} + +void QueueManagerFactory::destroyObject(QueueManager::Ptr pObject) +{ + try + { + pObject->disconnect(); + } + catch(...) + { + } +} + +QueueManagerPool::QueueManagerPool(Poco::SharedPtr factory, + std::size_t capacity, + std::size_t peakCapacity, + int idleTime) : + _factory(factory), + _capacity(capacity), + _peakCapacity(peakCapacity), + _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() +{ + for (std::vector >::iterator it = _pool.begin(); it != _pool.end(); ++it) + { + _factory->destroyObject((*it)->value()); + } +} + +QueueManager::Ptr QueueManagerPool::borrowObject() +{ + Poco::FastMutex::ScopedLock lock(_mutex); + + if (!_pool.empty()) + { + Poco::SharedPtr pObject = _pool.back(); + _pool.pop_back(); + return activateObject(pObject->value()); + } + + 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; +} + +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()); + _size--; + it = _pool.erase(it); + } + else ++it; + } +} + +} // Namespace MQ 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/MQDictionary/src/Application.cpp b/MQDictionary/src/Application.cpp index 0eb2c67..afb0a7a 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; @@ -129,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 @@ -295,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") @@ -302,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") @@ -400,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") @@ -414,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") @@ -441,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") @@ -481,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") @@ -505,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") @@ -540,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") @@ -555,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") @@ -612,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") ; @@ -678,9 +666,12 @@ 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, "") - (MQCACH_CONNECTION_NAME, "") + (MQCACH_CHANNEL_NAME, "ChannelName") + (MQCACH_CONNECTION_NAME) (MQBACF_EXTERNAL_UOW_ID, "ExternalUOWId") (MQIACF_HANDLE_STATE, "HandleState", DisplayMapInitializer (MQHSTATE_ACTIVE, "Active") @@ -699,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") @@ -712,8 +703,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") @@ -730,11 +721,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 @@ -742,23 +736,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") @@ -777,8 +759,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") @@ -815,6 +797,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 @@ -876,13 +859,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") @@ -919,11 +897,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") @@ -940,16 +921,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") @@ -962,23 +937,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") @@ -1024,7 +986,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 @@ -1070,7 +1032,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") @@ -1110,47 +1072,30 @@ 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") - (MQCACH_CONNECTION_NAME, "ConnectionName") + (MQCACH_CONNECTION_NAME) (MQIACH_DATA_CONVERSION, "DataConversion", DisplayMapInitializer (MQCDC_NO_SENDER_CONVERSION, "No") (MQCDC_SENDER_CONVERSION, "Sender") @@ -1209,7 +1154,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") @@ -1234,35 +1179,94 @@ 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) +#ifdef MQIA_USE_DEAD_LETTER_Q + (MQIA_USE_DEAD_LETTER_Q) +#endif + (MQCACH_USER_ID) // Extended Response - (MQBACF_RESPONSE_ID, "ResponseID") + (MQBACF_RESPONSE_ID) (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") ; Dictionary connectionDictionary = Dictionary() - (MQIA_APPL_TYPE, "") + (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_ALL, "All") + (MQQSGD_GROUP, "Group") + (MQQSGD_Q_MGR, "Queuemanager") + ) // 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") @@ -1271,7 +1275,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 @@ -1279,19 +1283,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") ; @@ -1305,7 +1300,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") @@ -1319,19 +1314,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") ; @@ -1397,7 +1383,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") @@ -1410,11 +1396,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") @@ -1423,141 +1412,211 @@ 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) - 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") (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) @@ -1630,8 +1689,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") @@ -1639,6 +1698,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") @@ -1652,22 +1712,39 @@ Dictionary eventDictionary = Dictionary() (MQOT_TOPIC, "Topic") (MQOT_COMM_INFO, "Communication Information") (MQOT_LISTENER, "Listener") - ) - (MQIACF_OPEN_OPTIONS, "OpenOptions") + (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) (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") (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") @@ -1700,7 +1777,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() @@ -2203,6 +2280,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 ) @@ -2236,6 +2566,126 @@ 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) +; + +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") + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") +; + +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") + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") +; + +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) + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") +; + +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) + // Extended Response + (MQBACF_RESPONSE_ID) + (MQCACF_RESPONSE_Q_MGR_NAME, "ResponseQMgrName") +; + class MQDictionary : public Poco::Util::Application { public: @@ -2345,7 +2795,11 @@ 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); + 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/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/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..310c238 --- /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, Poco::JSON::Object::Ptr input); + /// Constructor + + virtual ~AuthenticationInformationMapper(); + /// Destructor + + void change(); + /// Implements the change authentication information command. Not implemented yet. + + void create(bool replace = false); + /// Implements the create authentication information command. Not implemented yet. + + void copy(bool replace = false); + /// Implements the copy authentication information command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(); + /// Implements the inquire authentication information command. + +private: + + AuthenticationInformationMapper(const AuthenticationInformationMapper&); +}; + + +}} // Namespace MQ::Web + +#endif // _MQWeb_AuthenticationInformationMapper_H 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..b4aec17 --- /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, Poco::JSON::Object::Ptr input); + /// Constructor + + virtual ~AuthorityRecordMapper(); + /// Destructor + + void change(); + /// Implements the change authority records command. Not implemented yet. + + void create(bool replace = false); + /// Implements the create authority records command. Not implemented yet. + + void copy(bool replace = false); + /// Implements the copy authority records command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(); + /// Implements the inquire authority records command. + +private: + + AuthorityRecordMapper(const AuthorityRecordMapper&); +}; + + +}} // Namespace MQ::Web + +#endif // _MQWeb_AuthorityRecordMapper_H 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/ChannelMapper.h b/MQWeb/include/MQ/Web/ChannelMapper.h index 0cbfbb3..29fe8c1 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 @@ -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/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..dfcb0da 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 @@ -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 12dcbff..734470e 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 @@ -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/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..e2614d0 --- /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 connection object to/from Websphere MQ +{ +public: + + ConnectionMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); + /// Constructor + + virtual ~ConnectionMapper(); + /// Destructor + + void change(); + /// Not implemented. + + void create(bool replace = false); + /// Not implemented. + + void copy(bool replace = false); + /// Not implemented. + + Poco::JSON::Array::Ptr inquire(); + /// Implements the inquire connection command. + +private: + + ConnectionMapper(const ConnectionMapper&); + +}; + +}} // Namespace MQ::Web + +#endif // _MQWeb_ConnectionMapper_H diff --git a/MQWeb/include/MQ/Web/Controller.h b/MQWeb/include/MQ/Web/Controller.h index 168e27b..227a590 100644 --- a/MQWeb/include/MQ/Web/Controller.h +++ b/MQWeb/include/MQ/Web/Controller.h @@ -68,7 +68,11 @@ 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 + + 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. @@ -82,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. @@ -97,6 +102,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 +159,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(); } @@ -197,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/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/Dictionary.h b/MQWeb/include/MQ/Web/Dictionary.h index 0e59b3c..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 @@ -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; } 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/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/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/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/MQController.h b/MQWeb/include/MQ/Web/MQController.h index 8f4ef55..23b7340 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 { @@ -46,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); @@ -59,6 +60,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, @@ -73,10 +78,10 @@ class MQController : public Controller private: - QueueManager::Ptr _qmgr; + QueueManagerPoolGuard::Ptr _qmgrPoolGuard; - CommandServer::Ptr _commandServer; + CommandServer* _commandServer; Poco::JSON::Object::Ptr _mqwebData; @@ -88,11 +93,11 @@ class MQController : public Controller inline QueueManager::Ptr MQController::qmgr() { - return _qmgr; + return _qmgrPoolGuard->getObject(); } -inline CommandServer::Ptr MQController::commandServer() +inline CommandServer* MQController::commandServer() { return _commandServer; } diff --git a/MQWeb/include/MQ/Web/MQMapper.h b/MQWeb/include/MQ/Web/MQMapper.h index 315c8af..51deb8b 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 @@ -36,13 +36,17 @@ 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 Poco::SharedPtr dictionary() const; + //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 @@ -55,26 +59,91 @@ class MQMapper : public Mapper protected: - MQ::CommandServer& _commandServer; + void createCommand(MQLONG command); + Poco::JSON::Object::Ptr createJSON(const PCF& pcf); - Poco::SharedPtr _dictionary; + 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 + + 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(); + + Poco::JSON::Object::Ptr _input; + +private: + + CommandServer& _commandServer; + + Poco::SharedPtr _dictionary; static DictionaryCache _dictionaryCache; -}; + PCF::Ptr _pcf; + static Dictionary _operators; +}; + +template +inline void MQMapper::addParameter(MQLONG parameter, const std::string& name) +{ + poco_assert_dbg(!_pcf.isNull()); + + Poco::Dynamic::Var value = _input->get(name); + if (! value.isEmpty() ) + { + try + { + _pcf->addParameter(parameter, value.convert()); + } + catch(...) + { + poco_assert_dbg(false); + } + } +} +/* inline const Poco::SharedPtr MQMapper::dictionary() const { return _dictionary; } +*/ + +inline Poco::JSON::Object::Ptr MQMapper::createJSON(const PCF &pcf) +{ + 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) { return _dictionaryCache.getDictionary(objectType); } +inline void MQMapper::createCommand(MQLONG command) +{ + _pcf = _commandServer.createCommand(command); +} + +inline PCF::Ptr MQMapper::pcf() +{ + return _pcf; +} + }} // Namespace MQ::Web #endif // _MQWeb_MQMapper_H diff --git a/MQWeb/include/MQ/Web/Mapper.h b/MQWeb/include/MQ/Web/Mapper.h index 986f95a..4e764be 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 @@ -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/NamelistController.h b/MQWeb/include/MQ/Web/NamelistController.h new file mode 100644 index 0000000..27e2f9e --- /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 namelist +{ +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..fd1a8c6 --- /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 namelist object to/from Websphere MQ +{ +public: + + NamelistMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input); + /// Constructor + + virtual ~NamelistMapper(); + /// Destructor + + void change(); + /// Implements the change namelist command. Not implemented yet. + + void create(bool replace = false); + /// Implements the create namelist command. Not implemented yet. + + void copy(bool replace = false); + /// Implements the copy namelist command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(); + /// Implements the inquire namelist command. + +private: + + NamelistMapper(const NamelistMapper&); + +}; + +}} // Namespace MQ::Web + +#endif // _MQWeb_NamelistMapper_H 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..37fa3ff --- /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, Poco::JSON::Object::Ptr input); + /// Constructor + + virtual ~ProcessMapper(); + /// Destructor + + void change(); + /// Implements the change process command. Not implemented yet. + + void create(bool replace = false); + /// Implements the create process command. Not implemented yet. + + void copy(bool replace = false); + /// Implements the copy process command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(); + /// Implements the inquire process command. + +private: + + ProcessMapper(const ProcessMapper&); + +}; + +}} // Namespace MQ::Web + +#endif // _MQWeb_ProcessMapper_H diff --git a/MQWeb/include/MQ/Web/QueueManagerMapper.h b/MQWeb/include/MQ/Web/QueueManagerMapper.h index 54a012e..399aaef 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 @@ -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/QueueManagerPoolCache.h b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h new file mode 100644 index 0000000..cc27df0 --- /dev/null +++ b/MQWeb/include/MQ/Web/QueueManagerPoolCache.h @@ -0,0 +1,74 @@ +/* + * 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/ExpireCache.h" +#include "Poco/Dynamic/Struct.h" +#include "MQ/QueueManagerPool.h" + +namespace MQ { +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: + + QueueManagerPoolCache(); + /// Constructor. + + 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/include/MQ/Web/QueueManagerStatusMapper.h b/MQWeb/include/MQ/Web/QueueManagerStatusMapper.h index 74a0a94..360142c 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 @@ -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/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..60f2779 --- /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, Poco::JSON::Object::Ptr input); + /// Constructor + + virtual ~QueueStatusMapper(); + /// Destructor + + void change(); + /// Not available. + + void create(bool replace = false); + /// Not available. + + void copy(bool replace = false); + /// Not available. + + Poco::JSON::Array::Ptr inquire(); + /// Implements the inquire queue status command. + +private: + + QueueStatusMapper(const QueueStatusMapper&); +}; + + +}} // Namespace MQ::Web + +#endif // _MQWeb_QueueStatusMapper_H 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..41bf0bf --- /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, Poco::JSON::Object::Ptr input); + /// Constructor + + virtual ~ServiceMapper(); + /// Destructor + + void change(); + /// Implements the change service command. Not implemented yet. + + void create(bool replace = false); + /// Implements the create service command. Not implemented yet. + + void copy(bool replace = false); + /// Implements the copy service command. Not implemented yet. + + Poco::JSON::Array::Ptr inquire(); + /// Implements the inquire service command. + +private: + + ServiceMapper(const ServiceMapper&); + +}; + +}} // Namespace MQ::Web + +#endif // _MQWeb_ServiceMapper_H 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/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 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/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/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 diff --git a/MQWeb/src/Application.cpp b/MQWeb/src/Application.cpp index d9bc730..3286c8d 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); @@ -219,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/AuthenticationInformationController.cpp b/MQWeb/src/AuthenticationInformationController.cpp new file mode 100644 index 0000000..d695d62 --- /dev/null +++ b/MQWeb/src/AuthenticationInformationController.cpp @@ -0,0 +1,115 @@ +/* + * 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" + +namespace MQ +{ +namespace Web +{ + + +AuthenticationInformationController::AuthenticationInformationController() : MQController() +{ +} + + +AuthenticationInformationController::~AuthenticationInformationController() +{ +} + + +void AuthenticationInformationController::inquire() +{ + 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); + + 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(); + 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") ) + { + pcfParameters->set("CommandScope", form().get("CommandScope")); + } + + 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(), pcfParameters); + set("authinfos", mapper.inquire()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/AuthenticationInformationMapper.cpp b/MQWeb/src/AuthenticationInformationMapper.cpp new file mode 100644 index 0000000..cde093a --- /dev/null +++ b/MQWeb/src/AuthenticationInformationMapper.cpp @@ -0,0 +1,97 @@ +/* + * 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" + +namespace MQ { +namespace Web { + +AuthenticationInformationMapper::AuthenticationInformationMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "AuthenticationInformation", input) +{ +} + +AuthenticationInformationMapper::~AuthenticationInformationMapper() +{ +} + + +void AuthenticationInformationMapper::change() +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthenticationInformationMapper::create(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthenticationInformationMapper::copy(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire() +{ + createCommand(MQCMD_INQUIRE_AUTH_INFO); + + // Required parameters + addParameter(MQCA_AUTH_INFO_NAME, "AuthInfoName"); + + // Optional parameters + 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; + execute(commandResponse); + + bool excludeSystem = _input->optValue("ExcludeSystem", false); + + 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; + + 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; + } + + json->add(createJSON(**it)); + } + + return json; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/AuthorityRecordController.cpp b/MQWeb/src/AuthorityRecordController.cpp new file mode 100644 index 0000000..022a644 --- /dev/null +++ b/MQWeb/src/AuthorityRecordController.cpp @@ -0,0 +1,112 @@ +/* + * 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" + +namespace MQ +{ +namespace Web +{ + + +AuthorityRecordController::AuthorityRecordController() : MQController() +{ +} + + +AuthorityRecordController::~AuthorityRecordController() +{ +} + + +void AuthorityRecordController::inquire() +{ + 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; + + if ( data().has("filter") && data().isObject("filter") ) + { + 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 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); + } + + 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() && Poco::icompare(itOptions->first, "Options") == 0; + ++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(), pcfParameters); + set("authrecs", mapper.inquire()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/AuthorityRecordMapper.cpp b/MQWeb/src/AuthorityRecordMapper.cpp new file mode 100644 index 0000000..82cf129 --- /dev/null +++ b/MQWeb/src/AuthorityRecordMapper.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/AuthorityRecordMapper.h" + +namespace MQ { +namespace Web { + +AuthorityRecordMapper::AuthorityRecordMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "AuthorityRecord", input) +{ +} + + +AuthorityRecordMapper::~AuthorityRecordMapper() +{ +} + + +void AuthorityRecordMapper::change() +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthorityRecordMapper::create(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void AuthorityRecordMapper::copy(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire() +{ + createCommand(MQCMD_INQUIRE_AUTH_RECS); + + // Required parameters + MQLONG options = 0; + 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) + { + 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; + } + } + 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"); + + // Optional parameters + addParameter(MQCACF_ENTITY_NAME, "EntityName"); + addParameterNumFromString(MQIACF_ENTITY_TYPE, "EntityType"); + addAttributeList(MQIACF_AUTH_PROFILE_ATTRS, "ProfileAttrs"); + addParameter(MQCACF_SERVICE_COMPONENT, "ServiceComponent"); + + PCF::Vector 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; + + if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) + continue; + + json->add(createJSON(**it)); + } + + return json; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/ChannelController.cpp b/MQWeb/src/ChannelController.cpp index 99afc6c..ffbf1b6 100644 --- a/MQWeb/src/ChannelController.cpp +++ b/MQWeb/src/ChannelController.cpp @@ -18,10 +18,8 @@ * 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" namespace MQ { @@ -41,38 +39,88 @@ 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") ) { - filter->set("name", parameters[1]); - if ( parameters.size() > 2 ) + 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 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 ) { - filter->set("type", parameters[2]); + pcfParameters->set("ChannelName", parameters[1]); } else { - setResponseStatus(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST, "ChannelType is required when channelname is part of the URI-path"); - return; + // 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); } - } - 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); + + if ( parameters.size() > 2 ) + { + pcfParameters->set("ChannelType", parameters[2]); + } + else if ( form().has("ChannelType") ) + { + 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(); + formElementToJSONArray("ChannelAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for ChannelAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("ChannelAttrs", attrs); + } + + if ( form().has("CommandScope") ) + { + pcfParameters->set("CommandScope", form().get("CommandScope")); + } + + if ( form().has("QSGDisposition") ) + { + pcfParameters->set("QSGDisposition", form().get("QSGDisposition")); + } + + if ( form().has("DefaultChannelDisposition") ) + { + pcfParameters->set("DefaultChannelDisposition", form().get("DefaultChannelDisposition")); + } + + handleFilterForm(pcfParameters); } - ChannelMapper channelMapper(*commandServer()); - Poco::JSON::Array::Ptr jsonChannels = channelMapper.inquire(filter); - set("channels", jsonChannels); - setView(new JSONView()); + ChannelMapper mapper(*commandServer(), pcfParameters); + set("channels", mapper.inquire()); } diff --git a/MQWeb/src/ChannelMapper.cpp b/MQWeb/src/ChannelMapper.cpp index b12b47f..477d236 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 @@ -19,15 +19,13 @@ * permissions and limitations under the Licence. */ #include "MQ/Web/ChannelMapper.h" -#include "MQ/MQException.h" - -#include "Poco/JSON/Object.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) { } @@ -36,47 +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()); - - Poco::JSON::Array::Ptr channels = new Poco::JSON::Array(); + createCommand(MQCMD_INQUIRE_CHANNEL); - PCF::Ptr inquireChl = _commandServer.createCommand(MQCMD_INQUIRE_CHANNEL); + // Required Parameters + addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); - inquireChl->addParameter(MQCACH_CHANNEL_NAME, filter->optValue("name", "*")); - - std::string channelType = filter->optValue("type", "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); + // Optional Parameters + addParameterNumFromString(MQIACH_CHANNEL_TYPE, "ChannelType"); + addAttributeList(MQIACF_CHANNEL_ATTRS, "ChannelAttrs"); + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addParameterNumFromString(MQIACH_CHANNEL_DISP, "DefaultChannelDisposition"); + addIntegerFilter(); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireChl, commandResponse); + execute(commandResponse); + + bool excludeSystem = _input->optValue("ExcludeSystem", false); - bool excludeSystem = filter->optValue("excludeSystem", false); + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { @@ -93,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 0c60949..6664a39 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 @@ -18,10 +18,8 @@ * 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" namespace MQ { @@ -40,29 +38,75 @@ 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("IntegerFilterCommand", filter); + }; - ChannelStatusMapper channelStatusMapper(*commandServer()); - Poco::JSON::Array::Ptr statuses = channelStatusMapper.inquire(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); + } - set("statuses", statuses); - setView(new JSONView()); + 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")); + + handleFilterForm(pcfParameters); + } + ChannelStatusMapper mapper(*commandServer(), pcfParameters); + set("statuses", mapper.inquire()); } diff --git a/MQWeb/src/ChannelStatusMapper.cpp b/MQWeb/src/ChannelStatusMapper.cpp index 726cd08..c1fa572 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 @@ -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,56 +34,46 @@ 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()); - - Poco::JSON::Array::Ptr jsonStatuses = new Poco::JSON::Array(); - - PCF::Ptr inquireChlStatus = _commandServer.createCommand(MQCMD_INQUIRE_CHANNEL_STATUS); - - inquireChlStatus->addParameter(MQCACH_CHANNEL_NAME, filter->optValue("name", "*")); - - 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); - } - } - - 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); + createCommand(MQCMD_INQUIRE_CHANNEL_STATUS); + + // Required parameters + addParameter(MQCACH_CHANNEL_NAME, "ChannelName"); + + // Optional parameters + 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; - _commandServer.sendCommand(inquireChlStatus, commandResponse); + execute(commandResponse); + + Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { @@ -95,12 +83,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 6575505..66e8640 100644 --- a/MQWeb/src/ClusterQueueManagerController.cpp +++ b/MQWeb/src/ClusterQueueManagerController.cpp @@ -18,10 +18,8 @@ * 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" namespace MQ { @@ -41,29 +39,72 @@ 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 + // Third parameter is a cluster queuemanager + 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); + } + } + + 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")); + + 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()); - Poco::JSON::Array::Ptr clusqmgrs = mapper.inquire(filter); - set("clusqmgrs", clusqmgrs); - setView(new JSONView()); + ClusterQueueManagerMapper mapper(*commandServer(), pcfParameters); + set("clusqmgrs", mapper.inquire()); } diff --git a/MQWeb/src/ClusterQueueManagerMapper.cpp b/MQWeb/src/ClusterQueueManagerMapper.cpp index 50e0d11..3744ae8 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 @@ -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,50 +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()); - - Poco::JSON::Array::Ptr clusqmgrs = new Poco::JSON::Array(); + createCommand(MQCMD_INQUIRE_CLUSTER_Q_MGR); - PCF::Ptr inquireClusterQMgr = _commandServer.createCommand(MQCMD_INQUIRE_CLUSTER_Q_MGR); + // Required parameters + addParameter(MQCA_CLUSTER_Q_MGR_NAME, "ClusterQMgrName"); - if ( filter->has("clusterName") ) - { - inquireClusterQMgr->addParameter(MQCA_CLUSTER_NAME, filter->optValue("name", "*")); - } - - if ( filter->has("channelName") ) - { - inquireClusterQMgr->addParameter(MQCACH_CHANNEL_NAME, filter->optValue("channelName", "*")); - } - - if ( filter->has("clusterQmgrName") ) - { - inquireClusterQMgr->addParameter(MQCA_CLUSTER_Q_MGR_NAME, filter->optValue("clusterQmgrName", "*")); - } + // Optional parameters + 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; - _commandServer.sendCommand(inquireClusterQMgr, 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)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) @@ -88,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 new file mode 100644 index 0000000..8019e2d --- /dev/null +++ b/MQWeb/src/ConnectionController.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/ConnectionController.h" +#include "MQ/Web/ConnectionMapper.h" + +namespace MQ +{ +namespace Web +{ + +ConnectionController::ConnectionController() : MQController() +{ +} + + +ConnectionController::~ConnectionController() +{ + +} + + +void ConnectionController::inquire() +{ + 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); + + 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(), pcfParameters); + set("connections", mapper.inquire()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/ConnectionMapper.cpp b/MQWeb/src/ConnectionMapper.cpp new file mode 100644 index 0000000..72e7998 --- /dev/null +++ b/MQWeb/src/ConnectionMapper.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/ConnectionMapper.h" + +#include "Poco/HexBinaryDecoder.h" + +namespace MQ { +namespace Web { + + +ConnectionMapper::ConnectionMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Connection", input) +{ +} + +ConnectionMapper::~ConnectionMapper() +{ +} + + +void ConnectionMapper::change() +{ + poco_assert_dbg(false); // Not implemented +} + + +void ConnectionMapper::create(bool replace) +{ + poco_assert_dbg(false); // Not implemented +} + + +void ConnectionMapper::copy(bool replace) +{ + poco_assert_dbg(false); // Not implemented +} + + +Poco::JSON::Array::Ptr ConnectionMapper::inquire() +{ + createCommand(MQCMD_INQUIRE_CONNECTION); + + // Required parameters + if ( _input->has("ConnectionId") ) + { + std::string hexId = _input->get("ConnectionId"); + 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(); + } + + pcf()->addParameter(MQBACF_CONNECTION_ID, id); + } + else + { + BufferPtr id = new Buffer(0); // Empty buffer + pcf()->addParameter(MQBACF_GENERIC_CONNECTION_ID, id); + } + + // Optional parameters + //TODO: ByteStringFilter + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addAttributeList(MQIACF_CONNECTION_ATTRS, "ConnectionAttrs"); + addParameterNumFromString(MQIACF_CONN_INFO_TYPE, "ConnInfoType"); + addIntegerFilter(); + 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); + + 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) + continue; + + if ( (*it)->isExtendedResponse() ) // Skip extended response + continue; + + json->add(createJSON(**it)); + } + + return json; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/Controller.cpp b/MQWeb/src/Controller.cpp index 84c366b..f9d5b4f 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" @@ -28,7 +29,7 @@ #include "Poco/StreamCopier.h" #include "Poco/URI.h" -#include "Poco/JSON/TemplateCache.h" +#include "Poco/JSON/Parser.h" namespace MQ { @@ -79,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. @@ -109,26 +136,13 @@ void Controller::handle(const std::vector& parameters, Poco::Net::H } -bool Controller::isJSON() const +void Controller::setJSONView() { - 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; + 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() { if ( _view.isNull() ) return; // No view set, don't do anything @@ -148,6 +162,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) { diff --git a/MQWeb/src/ControllerRequestHandler.cpp b/MQWeb/src/ControllerRequestHandler.cpp index a606e1e..1c999fd 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 @@ -20,15 +20,22 @@ */ #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/AuthenticationInformationController.h" +#include "MQ/Web/AuthorityRecordController.h" #include "MQ/Web/ChannelController.h" #include "MQ/Web/ChannelStatusController.h" -#include "MQ/Web/MessageController.h" +#include "MQ/Web/ClusterQueueManagerController.h" +#include "MQ/Web/ConnectionController.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/ProcessController.h" +#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" @@ -112,6 +119,13 @@ void ControllerRequestHandler::registerControllers() _controllerFactory.registerClass("listener"); _controllerFactory.registerClass("lsstatus"); _controllerFactory.registerClass("clusqmgr"); + _controllerFactory.registerClass("conn"); + _controllerFactory.registerClass("nl"); + _controllerFactory.registerClass("process"); + _controllerFactory.registerClass("service"); + _controllerFactory.registerClass("qstatus"); + _controllerFactory.registerClass("authinfo"); + _controllerFactory.registerClass("authrec"); } 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..28e50b6 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 @@ -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); @@ -144,9 +153,20 @@ void Dictionary::mapToJSON(const PCF& pcf, Poco::JSON::Object::Ptr& json) const } } } + 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); } } } 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/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/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/ListenerController.cpp b/MQWeb/src/ListenerController.cpp index a8fae57..b2064a5 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 { @@ -40,34 +39,70 @@ 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()); - Poco::JSON::Array::Ptr listeners = mapper.inquire(filter); - set("listeners", listeners); - setView(new JSONView()); + ListenerMapper mapper(*commandServer(), pcfParameters); + set("listeners", mapper.inquire()); } diff --git a/MQWeb/src/ListenerMapper.cpp b/MQWeb/src/ListenerMapper.cpp index 281b29f..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,48 +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()); + createCommand(MQCMD_INQUIRE_LISTENER); - Poco::JSON::Array::Ptr listeners = new Poco::JSON::Array(); + // Required parameters + addParameter(MQCACH_LISTENER_NAME, "ListenerName"); - PCF::Ptr inquireListener = _commandServer.createCommand(MQCMD_INQUIRE_LISTENER); - inquireListener->addParameter(MQCACH_LISTENER_NAME, filter->optValue("name", "*")); - - 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 + addIntegerFilter(); + addAttributeList(MQIACF_LISTENER_ATTRS, "ListenerAttrs"); + addStringFilter(); + addParameterNumFromString(MQIACH_XMIT_PROTOCOL_TYPE, "TransportType"); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireListener, commandResponse); + execute(commandResponse); - bool excludeSystem = filter->optValue("excludeSystem", false); + bool excludeSystem = _input->optValue("ExcludeSystem", false); + 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 @@ -91,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 83bdc5e..b5d4ebf 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 { @@ -40,31 +39,61 @@ 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()); - Poco::JSON::Array::Ptr statuses = mapper.inquire(filter); - set("statuses", statuses); - setView(new JSONView()); + 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 23a11da..cf3d650 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,35 +33,42 @@ 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()); + createCommand(MQCMD_INQUIRE_LISTENER_STATUS); + + // Required parameters + addParameter(MQCACH_LISTENER_NAME, "ListenerName"); - Poco::JSON::Array::Ptr statuses = new Poco::JSON::Array(); - - PCF::Ptr inquireListenerStatus = _commandServer.createCommand(MQCMD_INQUIRE_LISTENER_STATUS); - inquireListenerStatus->addParameter(MQCACH_LISTENER_NAME, filter->optValue("name", "*")); + // Optional parameters + addIntegerFilter(); + addAttributeList(MQIACF_LISTENER_STATUS_ATTRS, "ListenerStatusAttrs"); + addStringFilter(); PCF::Vector commandResponse; - _commandServer.sendCommand(inquireListenerStatus, 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++) { if ( (*it)->isExtendedResponse() ) // Skip extended response @@ -71,10 +77,14 @@ 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); + std::string listenerName = (*it)->getParameterString(MQCACH_LISTENER_NAME); + if ( excludeSystem + && listenerName.compare(0, 7, "SYSTEM.") == 0 ) + { + continue; + } - dictionary()->mapToJSON(**it, status); + statuses->add(createJSON(**it)); } return statuses; diff --git a/MQWeb/src/MQController.cpp b/MQWeb/src/MQController.cpp index 530b4ff..8e1811f 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" @@ -33,7 +34,7 @@ namespace MQ { namespace Web { -MQController::MQController() : Controller(), _mqwebData(new Poco::JSON::Object()) +MQController::MQController() : Controller(), _mqwebData(new Poco::JSON::Object()), _commandServer(NULL) { set("mqweb", _mqwebData); } @@ -55,97 +56,68 @@ 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() ) + Poco::SharedPtr qmgrPool = QueueManagerPoolCache::instance()->getQueueManagerPool(qmgrName); + if ( qmgrPool.isNull() ) { - _qmgr->connect(); + //TODO: out of memory ??? } - else + + QueueManager::Ptr qmgr = qmgrPool->borrowObject(); + if ( qmgr.isNull() ) { - // 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) ) + //TODO: out of memory??? + } + _qmgrPoolGuard = new QueueManagerPoolGuard(qmgrPool, qmgr); + + _mqwebData->set("qmgr", qmgr->name()); + _mqwebData->set("zos", qmgr->zos()); + _mqwebData->set("qmgrId", qmgr->id()); + + _commandServer = qmgr->commandServer(); + if ( _commandServer == NULL ) + { + std::string qmgrConfigReplyQ = "mq.web.qmgr." + qmgrName + ".reply"; + + std::string replyQ; + if ( config.has(qmgrConfigReplyQ) ) { - 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); - } + replyQ = config.getString(qmgrConfigReplyQ); } - else // Hope that there is a channel tab file available + else { - _qmgr->connect(); + replyQ = config.getString("mq.web.reply", "SYSTEM.DEFAULT.MODEL.QUEUE"); } + _commandServer = qmgr->createCommandServer(replyQ); } - _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 modelQ; - if ( config.has(qmgrConfigModel) ) - { - modelQ = config.getString(qmgrConfigModel); - } - else + if ( _commandServer != NULL ) { - modelQ = config.getString("mq.web.reply", "SYSTEM.DEFAULT.MODEL.QUEUE"); + _mqwebData->set("replyq", _commandServer->replyQName()); + _mqwebData->set("cmdq", _commandServer->commandQName()); } - _mqwebData->set("replyq", modelQ); - _mqwebData->set("cmdq", _qmgr->commandQueue()); - - _commandServer = new CommandServer(_qmgr, modelQ); } @@ -170,13 +142,12 @@ void MQController::handleException(const MQException& mqe) if ( isJSON() ) { - setView(new JSONView()); + setJSONView(); } else { setView(new TemplateView("error.tpl")); } - } @@ -204,7 +175,7 @@ void MQController::handle(const std::vector& parameters, Poco::Net: catch(MQException& mqe) { handleException(mqe); - render(); + afterAction(); } catch(...) { @@ -212,5 +183,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 diff --git a/MQWeb/src/MQMapper.cpp b/MQWeb/src/MQMapper.cpp index 05b40b4..8ea4c7a 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 @@ -20,6 +20,8 @@ */ #include "MQ/Web/MQMapper.h" +#include "MQ/MQException.h" + #include "Poco/JSON/Object.h" #include "Poco/Logger.h" @@ -28,8 +30,26 @@ namespace Web { DictionaryCache MQMapper::_dictionaryCache; - -MQMapper::MQMapper(CommandServer& commandServer, const std::string& objectType) : _commandServer(commandServer) +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) + , _input(input) { _dictionary = _dictionaryCache.getDictionary(objectType); poco_assert_dbg(!_dictionary.isNull()); @@ -53,6 +73,10 @@ std::string MQMapper::getReasonString(MQLONG reasonCode) return dict->getDisplayValue(MQIACF_REASON_CODE, reasonCode); } +MQLONG MQMapper::getOperator(const std::string& op) +{ + return _operators.getId(op); +} const DisplayMap& MQMapper::getDisplayMap(const std::string& objectType, MQLONG id) { @@ -68,5 +92,121 @@ const DisplayMap& MQMapper::getDisplayMap(const std::string& objectType, MQLONG return dict->getDisplayMap(id); } +void MQMapper::addIntegerFilter() +{ + poco_assert_dbg(!_pcf.isNull()); + + Poco::JSON::Object::Ptr integerFilter = _input->getObject("IntegerFilterCommand"); + if ( integerFilter.isNull() ) + return; + + std::string parameterName = integerFilter->optValue("Parameter", ""); + MQLONG parameter = _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() ) + { + // 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::addStringFilter() +{ + 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 = _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::addAttributeList(MQLONG attrId, const std::string& attr) +{ + poco_assert_dbg(!_pcf.isNull()); + + if ( _input->has(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 = _dictionary->getId(*it); + if ( id != -1 ) numList.push_back(id); + } + if ( numList.size() > 0 ) _pcf->addParameterList(attrId, numList); + } + } +} + +void MQMapper::addParameterNumFromString(MQLONG parameter, const std::string& name) +{ + poco_assert_dbg(!_pcf.isNull()); + + Poco::Dynamic::Var value = _input->get(name); + if ( ! value.isEmpty() ) + { + try + { + std::string stringValue = value.convert(); + MQLONG numValue = _dictionary->getDisplayId(parameter, stringValue); + poco_assert_dbg(numValue != -1); + if ( numValue != - 1 ) + { + _pcf->addParameter(parameter, numValue); + } + } + catch(...) + { + poco_assert_dbg(false); + } + } +} + +void MQMapper::execute(PCF::Vector& 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 + && (*it)->getReasonCode() != MQRCCF_CHL_STATUS_NOT_FOUND ) + { + 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 diff --git a/MQWeb/src/MessageController.cpp b/MQWeb/src/MessageController.cpp index 6318cd6..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; @@ -270,8 +270,6 @@ void MessageController::browse() } set("messages", jsonMessages); - - setView(new JSONView()); } @@ -304,7 +302,7 @@ void MessageController::dump() return; } - Queue q(qmgr(), queueName); + Queue q(*qmgr(), queueName); q.open(MQOO_BROWSE); try @@ -443,8 +441,6 @@ void MessageController::dump() mapMessageToJSON(message, *jsonMessage); set("message", jsonMessage); - - setView(new JSONView()); } @@ -466,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; @@ -522,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) { @@ -531,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(); @@ -567,14 +562,32 @@ 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++; } - - setView(new JSONView()); } 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/NamelistController.cpp b/MQWeb/src/NamelistController.cpp new file mode 100644 index 0000000..4c7a1b0 --- /dev/null +++ b/MQWeb/src/NamelistController.cpp @@ -0,0 +1,119 @@ +/* + * 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" + +namespace MQ +{ +namespace Web +{ + +NamelistController::NamelistController() : MQController() +{ +} + + +NamelistController::~NamelistController() +{ + +} + + +void NamelistController::inquire() +{ + 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); + + 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")); + } + + 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()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/NamelistMapper.cpp b/MQWeb/src/NamelistMapper.cpp new file mode 100644 index 0000000..c9e2318 --- /dev/null +++ b/MQWeb/src/NamelistMapper.cpp @@ -0,0 +1,97 @@ +/* + * 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" + +namespace MQ { +namespace Web { + + +NamelistMapper::NamelistMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Namelist", input) +{ +} + +NamelistMapper::~NamelistMapper() +{ +} + + +void NamelistMapper::change() +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void NamelistMapper::create(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void NamelistMapper::copy(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr NamelistMapper::inquire() +{ + createCommand(MQCMD_INQUIRE_NAMELIST); + + // Required parameters + addParameter(MQCA_NAMELIST_NAME, "NamelistName"); + + // Optional parameters + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addIntegerFilter(); + addAttributeList(MQIACF_NAMELIST_ATTRS, "NamelistAttrs"); + addParameterNumFromString(MQIA_NAMELIST_TYPE, "NamelistType"); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addStringFilter(); + + PCF::Vector commandResponse; + execute(commandResponse); + + bool excludeSystem = _input->optValue("ExcludeSystem", false); + + 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) + 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; + } + + json->add(createJSON(**it)); + } + + return json; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/ProcessController.cpp b/MQWeb/src/ProcessController.cpp new file mode 100644 index 0000000..9ca77b6 --- /dev/null +++ b/MQWeb/src/ProcessController.cpp @@ -0,0 +1,111 @@ +/* + * 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" + +namespace MQ +{ +namespace Web +{ + +ProcessController::ProcessController() : MQController() +{ +} + + +ProcessController::~ProcessController() +{ + +} + + +void ProcessController::inquire() +{ + 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); + + 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(), pcfParameters); + set("processes", mapper.inquire()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/ProcessMapper.cpp b/MQWeb/src/ProcessMapper.cpp new file mode 100644 index 0000000..e0d27ed --- /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" + +namespace MQ { +namespace Web { + + +ProcessMapper::ProcessMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Process", input) +{ +} + +ProcessMapper::~ProcessMapper() +{ +} + + +void ProcessMapper::change() +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void ProcessMapper::create(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void ProcessMapper::copy(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr ProcessMapper::inquire() +{ + createCommand(MQCMD_INQUIRE_PROCESS); + + // Required parameters + addParameter(MQCA_PROCESS_NAME, "ProcessName"); + + // Optional parameters + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addIntegerFilter(); + addAttributeList(MQIACF_PROCESS_ATTRS, "ProcessAttrs"); + addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); + addStringFilter(); + + PCF::Vector commandResponse; + execute(commandResponse); + + bool excludeSystem = _input->optValue("ExcludeSystem", false); + + 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) + 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; + } + + json->add(createJSON(**it)); + } + + return json; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/QueueController.cpp b/MQWeb/src/QueueController.cpp index ad4219d..40b1215 100644 --- a/MQWeb/src/QueueController.cpp +++ b/MQWeb/src/QueueController.cpp @@ -18,11 +18,8 @@ * 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" namespace MQ { @@ -42,47 +39,148 @@ 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. If this is passed, the + // query parameter QName or queueName is ignored. + if ( parameters.size() > 1 ) + { + 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); + } + + 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") ) + { + int pageSetId = 0; + if ( Poco::NumberParser::tryParse(form().get("PageSetId"), pageSetId) ) + { + pcfParameters->set("PageSetId", pageSetId); + } + } + + if ( form().has("QSGDisposition") ) { - queueNameField = "*"; + pcfParameters->set("QSGDisposition", form().get("QSGDisposition")); } - 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") ) + handleFilterForm(pcfParameters); + + if ( form().has("QueueUsage") ) + { + pcfParameters->set("Usage", form().get("QueueUsage")); + } + else if ( form().has("Usage") ) { - filter->set("usage", form().get("queueUsage")); + 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); + std::string queueType; + if ( form().has("QueueType") ) + { + queueType = form().get("QueueType"); + } + else + { + queueType = form().get("QType", ""); + } + if ( !queueType.empty() ) + { + pcfParameters->set("QType", queueType); + } + + 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(); + formElementToJSONArray("QAttrs", attrs); + if ( attrs->size() == 0 ) // Nothing found for QAttrs, try Attrs + { + formElementToJSONArray("Attrs", attrs); + } + if ( attrs->size() > 0 ) + { + pcfParameters->set("QAttrs", attrs); + } } - QueueMapper mapper(*commandServer()); - Poco::JSON::Array::Ptr queues = mapper.inquire(filter); - 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 2ac1134..9ce8341 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,15 +39,39 @@ QueueManagerController::~QueueManagerController() void QueueManagerController::inquire() { - QueueManagerMapper queueManagerMapper(*commandServer()); + Poco::JSON::Object::Ptr pcfParameters; - Poco::JSON::Object::Ptr dummyFilter = new Poco::JSON::Object(); - Poco::JSON::Array::Ptr jsonQueueManagers = queueManagerMapper.inquire(dummyFilter); + 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")); + } + } - if ( jsonQueueManagers->size() > 0 ) + QueueManagerMapper mapper(*commandServer(), pcfParameters); + Poco::JSON::Array::Ptr json = mapper.inquire(); + if ( json->size() > 0 ) { - set("qmgr", jsonQueueManagers->get(0)); - setView(new JSONView()); + set("qmgr", json->get(0)); } } diff --git a/MQWeb/src/QueueManagerMapper.cpp b/MQWeb/src/QueueManagerMapper.cpp index 5f14bc8..843b652 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 @@ -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,45 +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(); + createCommand(MQCMD_INQUIRE_Q_MGR); - PCF::Ptr inquireQmgr = _commandServer.createCommand(MQCMD_INQUIRE_Q_MGR); + // Optional parameters + addParameter(MQCACF_COMMAND_SCOPE, "CommandScope"); + addAttributeList(MQIACF_Q_MGR_ATTRS, "QMgrAttrs"); std::vector > commandResponse; - _commandServer.sendCommand(inquireQmgr, 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/QueueManagerPoolCache.cpp b/MQWeb/src/QueueManagerPoolCache.cpp new file mode 100644 index 0000000..6ccf693 --- /dev/null +++ b/MQWeb/src/QueueManagerPoolCache.cpp @@ -0,0 +1,160 @@ +/* + * 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 "Poco/Util/Application.h" + +#include "MQ/MQSubsystem.h" + +#include "MQ/Web/QueueManagerPoolCache.h" + +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) +{ + QueueManagerPool::Ptr 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); + } + } + + return pool; +} + +void QueueManagerPoolCache::clear() +{ + _cache.clear(); +} + +QueueManagerPool::Ptr QueueManagerPoolCache::createPool(const std::string& qmgrName) +{ + QueueManagerPool::Ptr pool; + + MQSubsystem& mqSystem = Poco::Util::Application::instance().getSubsystem(); + Poco::Util::LayeredConfiguration& config = Poco::Util::Application::instance().config(); + + std::string qmgrConfig = "mq.web.qmgr." + qmgrName; + + Poco::SharedPtr factory; + + if ( mqSystem.client() ) + { + 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) ) + { + 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)); + } + } + + factory = new QueueManagerFactory(qmgrName, connectionInformation); + } + else + { + factory = new QueueManagerFactory(qmgrName); + } + } + else + { + 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; +} + +} } // Namespace MQ diff --git a/MQWeb/src/QueueManagerStatusController.cpp b/MQWeb/src/QueueManagerStatusController.cpp index c726616..13d0b58 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,15 +46,35 @@ void QueueManagerStatusController::inquire() return; } - QueueManagerStatusMapper queueManagerStatusMapper(*commandServer()); + Poco::JSON::Object::Ptr pcfParameters; - Poco::JSON::Object::Ptr dummyFilter = new Poco::JSON::Object(); - Poco::JSON::Array::Ptr jsonQueueManagers = queueManagerStatusMapper.inquire(dummyFilter); + 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 ( jsonQueueManagers->size() > 0 ) + if ( json->size() > 0 ) { - set("status", jsonQueueManagers->get(0)); - setView(new JSONView()); + set("status", json->get(0)); } } diff --git a/MQWeb/src/QueueManagerStatusMapper.cpp b/MQWeb/src/QueueManagerStatusMapper.cpp index 0f5d054..97a4859 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 @@ -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,57 +34,47 @@ 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() { - Poco::JSON::Array::Ptr jsonQueueManagerStatuses = new Poco::JSON::Array(); + createCommand(MQCMD_INQUIRE_Q_MGR_STATUS); - PCF::Ptr inquireQmgr = _commandServer.createCommand(MQCMD_INQUIRE_Q_MGR_STATUS); + // Optional parameters + addAttributeList(MQIACF_Q_MGR_STATUS_ATTRS, "QMStatusAttrs"); std::vector > commandResponse; - _commandServer.sendCommand(inquireQmgr, commandResponse); + execute(commandResponse); - if ( commandResponse.size() > 0 ) + Poco::JSON::Array::Ptr json = 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; + + json->add(createJSON(**it)); } - return jsonQueueManagerStatuses; + return json; } }} // Namespace MQ::Web diff --git a/MQWeb/src/QueueMapper.cpp b/MQWeb/src/QueueMapper.cpp index 73d95fb..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,66 +33,78 @@ 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()); + createCommand(MQCMD_INQUIRE_Q); - Poco::JSON::Array::Ptr jsonQueues = new Poco::JSON::Array(); + // Required Parameters + addParameter(MQCA_Q_NAME, "QName"); - PCF::Ptr inquireQ = _commandServer.createCommand(MQCMD_INQUIRE_Q); - inquireQ->addParameter(MQCA_Q_NAME, filter->optValue("name", "*")); - if ( filter->has("qdepth") ) + // Optional Parameters + addParameter(MQCA_CF_STRUC_NAME, "CFStructure"); + + Poco::Dynamic::Var clusterInfo = _input->get("ClusterInfo"); + if (! clusterInfo.isEmpty() ) { - inquireQ->addFilter(MQIA_CURRENT_Q_DEPTH, MQCFOP_NOT_LESS, filter->getValue("qdepth")); + try + { + pcf()->addParameter(MQIACF_CLUSTER_INFO, clusterInfo.convert() == true); + } + catch(...) + { + poco_assert_dbg(false); + } } + 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 ( usageValue.compare("xmitq") == 0 ) + std::string usageValue = _input->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"); - MQLONG queueTypeValue = dictionary()->getDisplayId(MQIA_Q_TYPE, queueType); - poco_assert_dbg(queueTypeValue != -1); - if ( queueTypeValue == - 1 ) - { - return jsonQueues; - } - inquireQ->addParameter(MQIA_Q_TYPE, queueTypeValue); - PCF::Vector commandResponse; - _commandServer.sendCommand(inquireQ, 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++) { if ( (*it)->isExtendedResponse() ) // Skip extended response @@ -125,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 new file mode 100644 index 0000000..331f3c7 --- /dev/null +++ b/MQWeb/src/QueueStatusController.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/QueueStatusController.h" +#include "MQ/Web/QueueStatusMapper.h" + +namespace MQ +{ +namespace Web +{ + + +QueueStatusController::QueueStatusController() : MQController() +{ +} + + +QueueStatusController::~QueueStatusController() +{ +} + + +void QueueStatusController::inquire() +{ + 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); + + 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 ) + { + 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); + } + + 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(), pcfParameters); + set("statuses", mapper.inquire()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/QueueStatusMapper.cpp b/MQWeb/src/QueueStatusMapper.cpp new file mode 100644 index 0000000..2df0b33 --- /dev/null +++ b/MQWeb/src/QueueStatusMapper.cpp @@ -0,0 +1,107 @@ +/* + * 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" + +namespace MQ { +namespace Web { + +QueueStatusMapper::QueueStatusMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "QueueStatus", input) +{ +} + +QueueStatusMapper::~QueueStatusMapper() +{ +} + + +void QueueStatusMapper::change() +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void QueueStatusMapper::create(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void QueueStatusMapper::copy(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr QueueStatusMapper::inquire() +{ + createCommand(MQCMD_INQUIRE_Q_STATUS); + + // Required parameters + addParameter(MQCA_Q_NAME, "QName"); + + // Optional parameters + //TODO: ByteStringFilter + 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; + execute(commandResponse); + + 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++) + { + 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; + } + + json->add(createJSON(**it)); + } + + return json; +} + +}} // Namespace MQ::Web diff --git a/MQWeb/src/ServiceController.cpp b/MQWeb/src/ServiceController.cpp new file mode 100644 index 0000000..ec56382 --- /dev/null +++ b/MQWeb/src/ServiceController.cpp @@ -0,0 +1,102 @@ +/* + * 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 pcfParameters; + + if ( data().has("filter") && data().isObject("filter") ) + { + 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 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(), pcfParameters); + set("services", mapper.inquire()); +} + + +} } // Namespace MQ::Web diff --git a/MQWeb/src/ServiceMapper.cpp b/MQWeb/src/ServiceMapper.cpp new file mode 100644 index 0000000..ba090f8 --- /dev/null +++ b/MQWeb/src/ServiceMapper.cpp @@ -0,0 +1,93 @@ +/* + * 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" + +namespace MQ { +namespace Web { + + +ServiceMapper::ServiceMapper(CommandServer& commandServer, Poco::JSON::Object::Ptr input) +: MQMapper(commandServer, "Service", input) +{ +} + +ServiceMapper::~ServiceMapper() +{ +} + + +void ServiceMapper::change() +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void ServiceMapper::create(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +void ServiceMapper::copy(bool replace) +{ + poco_assert_dbg(false); // Not yet implemented +} + + +Poco::JSON::Array::Ptr ServiceMapper::inquire() +{ + createCommand(MQCMD_INQUIRE_SERVICE); + + // Required parameters + addParameter(MQCA_SERVICE_NAME, "ServiceName"); + + // Optional parameters + addIntegerFilter(); + addAttributeList(MQIACF_SERVICE_ATTRS, "ServiceAttrs"); + addStringFilter(); + + PCF::Vector commandResponse; + execute(commandResponse); + + bool excludeSystem = _input->optValue("ExcludeSystem", false); + + 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) + 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; + } + + json->add(createJSON(**it)); + } + + return json; +} + +}} // Namespace MQ::Web 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 diff --git a/poco.lua b/poco.lua index 543ab88..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" 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(); diff --git a/samples/perl/authinfo_inq.pl b/samples/perl/authinfo_inq.pl new file mode 100644 index 0000000..75ed5eb --- /dev/null +++ b/samples/perl/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/perl/authrec_inq.pl b/samples/perl/authrec_inq.pl new file mode 100644 index 0000000..fdce1a0 --- /dev/null +++ b/samples/perl/authrec_inq.pl @@ -0,0 +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 = 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->encode(\%input)); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); diff --git a/samples/perl/channel_inq.pl b/samples/perl/channel_inq.pl new file mode 100644 index 0000000..d9d941a --- /dev/null +++ b/samples/perl/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/perl/chstatus_inq.pl b/samples/perl/chstatus_inq.pl new file mode 100644 index 0000000..e842e46 --- /dev/null +++ b/samples/perl/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())); diff --git a/samples/perl/clusqmgr_inq.pl b/samples/perl/clusqmgr_inq.pl new file mode 100644 index 0000000..7416c03 --- /dev/null +++ b/samples/perl/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())); diff --git a/samples/perl/conn_inq.pl b/samples/perl/conn_inq.pl new file mode 100644 index 0000000..003ed24 --- /dev/null +++ b/samples/perl/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())); diff --git a/samples/perl/listener_inq.pl b/samples/perl/listener_inq.pl new file mode 100644 index 0000000..cb61c3a --- /dev/null +++ b/samples/perl/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())); 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/namelist_inq.pl b/samples/perl/namelist_inq.pl new file mode 100644 index 0000000..8389f37 --- /dev/null +++ b/samples/perl/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())); diff --git a/samples/perl/process_inq.pl b/samples/perl/process_inq.pl new file mode 100644 index 0000000..e3724be --- /dev/null +++ b/samples/perl/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())); 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/qmstatus_inq.pl b/samples/perl/qmstatus_inq.pl new file mode 100644 index 0000000..a9897fe --- /dev/null +++ b/samples/perl/qmstatus_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/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())); diff --git a/samples/perl/queue_inq.pl b/samples/perl/queue_inq.pl new file mode 100644 index 0000000..e491135 --- /dev/null +++ b/samples/perl/queue_inq.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl +use strict; +use warnings; +use feature qw(say); + +use JSON; +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); + +my $json = JSON->new; + +my %input = ( + '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', + 'Content-length' => length($content) +); +$req->content($content); + +my $res = $ua->request($req); +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 { + foreach my $queue(@{$mqweb->{queues}}) { + my $output = $queue->{QName}->{value}; + $output .= ' : ' . $queue->{CurrentQDepth}->{value} + if ( exists($queue->{CurrentQDepth}) ); + say $output; + } +} diff --git a/samples/perl/service_inq.pl b/samples/perl/service_inq.pl new file mode 100644 index 0000000..a6ea8cb --- /dev/null +++ b/samples/perl/service_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 = ( + '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', + 'Content-length' => length($content) +); +$req->content($content); + +my $res = $ua->request($req); + +print $json->pretty->encode($json->decode($res->content())); diff --git a/samples/php/authinfo_inq.php b/samples/php/authinfo_inq.php new file mode 100644 index 0000000..a1f4c18 --- /dev/null +++ b/samples/php/authinfo_inq.php @@ -0,0 +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/authrec_inq.php b/samples/php/authrec_inq.php new file mode 100644 index 0000000..64a1d74 --- /dev/null +++ b/samples/php/authrec_inq.php @@ -0,0 +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/channel_inq.php b/samples/php/channel_inq.php new file mode 100644 index 0000000..8245d02 --- /dev/null +++ b/samples/php/channel_inq.php @@ -0,0 +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"; + } + } + } diff --git a/samples/php/chstatus_inq.php b/samples/php/chstatus_inq.php new file mode 100644 index 0000000..cbcd066 --- /dev/null +++ b/samples/php/chstatus_inq.php @@ -0,0 +1,37 @@ +error) ) { + echo "An MQ error occurred while inquiring channel statuses.\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"; + } + } + } diff --git a/samples/php/clusqmgr_inq.php b/samples/php/clusqmgr_inq.php new file mode 100644 index 0000000..ffa5eb4 --- /dev/null +++ b/samples/php/clusqmgr_inq.php @@ -0,0 +1,38 @@ +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/conn_inq.php b/samples/php/conn_inq.php new file mode 100644 index 0000000..619fbe7 --- /dev/null +++ b/samples/php/conn_inq.php @@ -0,0 +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/guzzle.php b/samples/php/guzzle.php similarity index 80% rename from samples/guzzle.php rename to samples/php/guzzle.php index 7a67a57..d844cd8 100644 --- a/samples/guzzle.php +++ b/samples/php/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); diff --git a/samples/php/listener_inq.php b/samples/php/listener_inq.php new file mode 100644 index 0000000..dfb9f8b --- /dev/null +++ b/samples/php/listener_inq.php @@ -0,0 +1,15 @@ +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/qmgr_inq.php b/samples/php/qmgr_inq.php new file mode 100644 index 0000000..4171283 --- /dev/null +++ b/samples/php/qmgr_inq.php @@ -0,0 +1,40 @@ +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 new file mode 100644 index 0000000..8aae7e0 --- /dev/null +++ b/samples/php/qmstatus_inq.php @@ -0,0 +1,42 @@ +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->status) ) { + echo $json->status->QMgrName->value + . ' started on ' + . $json->status->StartDate->value + . ' ' + . $json->status->StartTime->value + . PHP_EOL; + } + else { + echo 'No status found' . PHP_EOL; + } + } + } diff --git a/samples/php/queue_inq.php b/samples/php/queue_inq.php new file mode 100644 index 0000000..acd014a --- /dev/null +++ b/samples/php/queue_inq.php @@ -0,0 +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"; + } + } + } 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 new file mode 100755 index 0000000..5250c2b --- /dev/null +++ b/samples/pygmentize_samples.sh @@ -0,0 +1,37 @@ +#!/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/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/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/php/channel_inq.html ./php/channel_inq.php +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/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/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/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/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/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/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/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 + diff --git a/samples/queue.php b/samples/queue.php deleted file mode 100644 index d9fa73d..0000000 --- a/samples/queue.php +++ /dev/null @@ -1,16 +0,0 @@ -