Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fbraem committed Dec 19, 2018
2 parents c651014 + 51374af commit ae0e56f
Show file tree
Hide file tree
Showing 206 changed files with 6,055 additions and 3,509 deletions.
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
cmake_minimum_required(VERSION 2.6)

option(MQWEB_ODBC "Use ODBC for configuration" OFF)
option(POCO_INSTALLED "Poco Installed" ON)
set(POCO_PREFIX "" CACHE STRING "Prefix Path for POCO")
if (UNIX)
set(MQ_INSTALLATION_PATH "/opt/mqm" CACHE STRING "MQ Installation Path")
set(MQ_INCLUDE "${MQ_INSTALLATION_PATH}/inc")
set(MQ_LIB "${MQ_INSTALLATION_PATH}/lib64")
else()
set(MQ_INSTALLATION_PATH "C:\\Program Files\\IBM\\WebSphere MQ" CACHE STRING "MQ Installation Path")
set(MQ_INCLUDE "${MQ_INSTALLATION_PATH}\\Tools\\c\\include")
set(MQ_LIB "${MQ_INSTALLATION_PATH}\\Tools\\Lib64")
endif()

project(MQWebSolution)

Expand All @@ -13,8 +23,13 @@ else()
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin/release)
endif()

foreach(pocolib Foundation Util XML Net JSON Data DataSQLite)
set(PocoLibList Foundation;Util;XML;Net;JSON;Data;DataSQLite)
if (MQWEB_ODBC)
message(STATUS "Adding ODBC support")
list(APPEND PocoLibList DataODBC)
endif()

foreach(pocolib ${PocoLibList})
if (CMAKE_BUILD_TYPE STREQUAL Debug)
set(pocolibname ${pocolib}d)
else()
Expand Down Expand Up @@ -46,6 +61,8 @@ foreach(pocolib Foundation Util XML Net JSON Data DataSQLite)
set(POCO_INC_H Poco/${pocolib}.h)
elseif(pocolib STREQUAL "DataSQLite")
set(POCO_INC_H Poco/Data/SQLite/SQLite.h)
elseif(pocolib STREQUAL "DataODBC")
set(POCO_INC_H Poco/Data/ODBC/ODBC.h)
else()
set(POCO_INC_H Poco/${pocolib}/${pocolib}.h)
endif()
Expand All @@ -58,6 +75,8 @@ foreach(pocolib Foundation Util XML Net JSON Data DataSQLite)
else()
if (pocolib STREQUAL "DataSQLite")
set(POCO_INC_SEARCH_PATH "${POCO_PREFIX}/Data/SQLite/include")
elseif(pocolib STREQUAL "DataODBC")
set(POCO_INC_SEARCH_PATH "${POCO_PREFIX}/Data/ODBC/include")
else()
set(POCO_INC_SEARCH_PATH "${POCO_PREFIX}/${pocolib}/include")
endif()
Expand Down Expand Up @@ -85,4 +104,4 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
add_subdirectory(MQ)
add_subdirectory(MQWeb)
add_subdirectory(MQCheck)
add_subdirectory(MQDictionary)
add_subdirectory(MQDictionary)
16 changes: 16 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
0.1.1
- Return a HTTP status when a POCO exception occurs.
- Improve queuemanager pool management
- Add clear queue
- Add ping qmgr
- Add get message
- Add browse message
- Add inquire chlauth
- Add set chlauth
- Browse statistics/accounting messages
- Browse RFH messages
- Add create queue
- Add delete queue
- Add copy queue
- Queuemanager configuration can be read from ODBC

0.1.0
- Web app has its own repository now: mqwebapp
- 'filter' renamed to 'input' in mqweb JSON answer
Expand Down
2 changes: 1 addition & 1 deletion MQ/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set (PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)

file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/*.cpp")

include_directories("${PROJECT_INCLUDE_DIR}" "${POCO_Foundation_INCLUDE}" "${POCO_Util_INCLUDE}" "/opt/mqm/inc")
include_directories("${PROJECT_INCLUDE_DIR}" "${POCO_Foundation_INCLUDE}" "${POCO_Util_INCLUDE}" "${MQ_INCLUDE}")

add_library(mq STATIC ${SOURCES})
set_target_properties(mq PROPERTIES DEBUG_POSTFIX "d")
8 changes: 4 additions & 4 deletions MQ/include/MQ/CommandServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class CommandServer
/// Class for sending PCF commands to a queuemanager
{
public:
CommandServer(Poco::SharedPtr<QueueManager> qmgr, const std::string& modelQueue);
/// Constructor.

std::string commandQName() const;
/// Returns the name of the command queue.

Expand All @@ -51,13 +54,10 @@ class CommandServer
/// Returns the name of the reply queue.

private:
CommandServer(QueueManager& qmgr, const std::string& modelQueue);
/// Constructor.

CommandServer(const CommandServer& copy);
CommandServer& operator = (const CommandServer& copy);

QueueManager& _qmgr;
Poco::SharedPtr<QueueManager> _qmgr;

Queue _commandQ;

Expand Down
12 changes: 7 additions & 5 deletions MQ/include/MQ/MessageConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MessageConsumer
GET
};

MessageConsumer(QueueManager& qmgr, const std::string& queueName, Action action = BROWSE);
MessageConsumer(QueueManager::Ptr qmgr, const std::string& queueName, Action action = BROWSE);
/// Constructor. Can throw a MQException.

virtual ~MessageConsumer();
Expand Down Expand Up @@ -81,18 +81,20 @@ class MessageConsumer
void stop();
/// Stops the consumer. Can throw a MQException.

typedef Poco::BasicEvent<Poco::SharedPtr<Message> > Event;
typedef Poco::BasicEvent<Poco::SharedPtr<Message> > MessageEvent;
MessageEvent messageEvent;

Event message;
typedef Poco::BasicEvent<MQLONG> ErrorEvent;
ErrorEvent errorEvent;

private:

static void consume(MQHCONN conn, MQMD* md, MQGMO* gmo, MQBYTE* buffer, MQCBC* context);
/// Callback for MQCB

QueueManager& _qmgr;
QueueManager::Ptr _qmgr;

Queue _queue;
Queue::Ptr _queue;

Action _action;

Expand Down
148 changes: 42 additions & 106 deletions MQ/include/MQ/PCF.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
#include <cmqc.h>
#include <cmqcfc.h> /* PCF */

#include <map>
#include <vector>

#include "Poco/DateTime.h"
#include "MQ/Message.h"
#include "MQ/PCFParameters.h"

namespace MQ {

Expand Down Expand Up @@ -67,111 +66,62 @@ class PCF
void addFilter(MQLONG parameter, MQLONG op, MQLONG value);
/// Add a filter with a numeric value.

const PCFParameters& getParameters() const;
/// Returns the parameters

bool hasParameter(MQLONG id) const;
/// Returns true when the parameter is found in the PCF message.

int getCommand() const;
/// Returns the command.

int getCompletionCode() const;
/// Returns the completion code.

int getControl() const;
/// Returns the PCF message sequence number

int getMessageSequenceNumber() const;
/// Returns the PCF message sequence number

int getReasonCode() const;
/// Returns the reason code.

bool isByteString(MQLONG parameter) const;
/// Returns true when the value of the parameter is a byte string.

bool isExtendedResponse() const;
/// Returns true when this is an extended response.

bool isNumber(MQLONG parameter) const;
/// Returns true when the value of the parameter is a numeric value.

bool isNumberList(MQLONG parameter) const;
/// Returns true when the value of the parameter is a numeric list.

bool isString(MQLONG parameter) const;
/// Returns true when the value of the parameter is a string value.
/// Note: a byte string will also return true! When getParameterString is called
/// a byte string will be returned as hex. Use isByteString to check if a
/// value contains byte string

bool isStringList(MQLONG parameter) const;
/// Returns true when the value of the parameter is a string list value.

bool isLast() const;
/// Returns true when this PCF message is the last of a response.

Poco::DateTime getParameterDate(MQLONG dateParameter, MQLONG timeParameter) const;
/// Combines a date and time parameter and returns it as a DateTime object
/// When the date parameter doesn't exist, the current date is returned.

MQLONG getParameterNum(MQLONG parameter) const;
/// Returns the numeric value of a parameter.
/// Poco::NotFoundException will be thrown when the parameter isn't found.
/// Poco::BadCastException will be thrown when the parameter doesn't contain a numeric value.

std::vector<MQLONG> getParameterNumList(MQLONG parameter) const;
/// Returns a numeric list.
/// Poco::NotFoundException will be thrown when the parameter isn't found.
/// Poco::BadCastException will be thrown when the parameter doesn't contain a numeric list value.

std::string getParameterString(MQLONG parameter) const;
/// Returns the string value of a parameter. A byte string is converted to a hex value.
/// If you need the real byte string, use getParameterByteString.
/// Poco::NotFoundException will be thrown when the parameter isn't found.
/// Poco::BadCastException will be thrown when the parameter doesn't contain a string or byte string value.

Buffer::Ptr getParameterByteString(MQLONG parameter) const;
/// Returns the byte string value as a buffer.
/// Poco::NotFoundException will be thrown when the parameter isn't found.
/// Poco::BadCastException will be thrown when the parameter doesn't contain a byte string value.

std::vector<std::string> getParameterStringList(MQLONG parameter) const;
/// Returns a vector of strings of a parameter.
/// Poco::NotFoundException will be thrown when the parameter isn't found.
/// Poco::BadCastException will be thrown when the parameter doesn't contain a string list.

bool hasParameter(MQLONG parameter) const;
/// Returns true when the parameter is found in the PCF message.

std::vector<MQLONG> getParameters() const;
/// Returns a vector with all parameter ids.

Message::Ptr message() const;

MQLONG optParameterNum(MQLONG parameter, MQLONG def = 0) const;
/// Returns the numeric value of a parameter.
/// When the parameter isn't found or doesn't contain a numeric value,
/// def will be returned.

std::string optParameterString(MQLONG parameter, const std::string& def = "") const;
/// Returns the string value of a parameter.
/// When the parameter doesn't exist or is not a string, an empty
/// string is returned.

typedef Poco::SharedPtr<PCF> Ptr;


typedef std::vector<Ptr> Vector;


static Ptr create(Message::Ptr message, bool zos = false);

private:

Message::Ptr _message;

std::map<MQLONG, size_t> _pointers;

bool _zos;


bool _zos;
PCFParameters _parameters;


PCF(const PCF& pcf);
/// Don't allow a copy

void incrementParameterCount();
/// Increment the parameter counter in the PCF header.

friend class CommandServer;


bool isType(MQLONG parameter, MQLONG type) const;
/// Returns true when the parameter is of given type.
};

inline void PCF::addParameterList(MQLONG parameter, const std::vector<MQLONG>& values)
Expand All @@ -191,66 +141,52 @@ inline int PCF::getCompletionCode() const
return header->CompCode;
}

inline int PCF::getReasonCode() const
inline const PCFParameters& PCF::getParameters() const
{
MQCFH* header = (MQCFH*)(MQBYTE*) _message->buffer().data();
return header->Reason;
return _parameters;
}

inline bool PCF::isByteString(MQLONG parameter) const
inline int PCF::getMessageSequenceNumber() const
{
return isType(parameter, MQCFT_BYTE_STRING);
MQCFH* header = (MQCFH*)(MQBYTE*)_message->buffer().data();
return header->MsgSeqNumber;
}

inline bool PCF::isExtendedResponse() const
inline int PCF::getControl() const
{
MQCFH* header = (MQCFH*)(MQBYTE*) _message->buffer().data();
return header->Type == MQCFT_XR_SUMMARY;
MQCFH* header = (MQCFH*)(MQBYTE*)_message->buffer().data();
return header->Control;
}


inline bool PCF::hasParameter(MQLONG parameter) const
{
return _pointers.find(parameter) != _pointers.end();
}

inline bool PCF::isLast() const
inline int PCF::getReasonCode() const
{
MQCFH* header = (MQCFH*)(MQBYTE*) _message->buffer().data();
return header->Control == MQCFC_LAST;
return header->Reason;
}

inline bool PCF::isNumber(MQLONG parameter) const
inline bool PCF::hasParameter(MQLONG id) const
{
return isType(parameter, MQCFT_INTEGER);
return _parameters.has(id);
}

inline bool PCF::isNumberList(MQLONG parameter) const
inline void PCF::incrementParameterCount()
{
return isType(parameter, MQCFT_INTEGER_LIST);
MQCFH* header = (MQCFH*) (MQBYTE*) _message->buffer().data();
header->ParameterCount++;
}


inline bool PCF::isString(MQLONG parameter) const
inline bool PCF::isExtendedResponse() const
{
return isType(parameter, MQCFT_STRING) || isType(parameter, MQCFT_BYTE_STRING);
MQCFH* header = (MQCFH*)(MQBYTE*) _message->buffer().data();
return header->Type == MQCFT_XR_SUMMARY;
}

inline bool PCF::isStringList(MQLONG parameter) const
inline bool PCF::isLast() const
{
return isType(parameter, MQCFT_STRING_LIST);
MQCFH* header = (MQCFH*)(MQBYTE*) _message->buffer().data();
return header->Control == MQCFC_LAST;
}

inline bool PCF::isType(MQLONG parameter, MQLONG type) const
{
std::map<MQLONG, size_t>::const_iterator it = _pointers.find(parameter);
if ( it != _pointers.end() )
{
MQLONG *pcfType = (MQLONG*) _message->buffer().data(it->second);
return *pcfType == type;
}
return false;
}

inline Message::Ptr PCF::message() const
{
Expand Down
Loading

0 comments on commit ae0e56f

Please sign in to comment.