<commit_before>/*
 * Copyright 2010 MQWeb - <NAME>
 *
 * Licensed under the EUPL, Version 1.1 or ? as soon they
 * will be approved by the European Commission - subsequent
 * versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the
 * Licence.
 * You may obtain a copy of the Licence at:
 *
 * http://joinup.ec.europa.eu/software/page/eupl
 *
 * Unless required by applicable law or agreed to in
 * writing, software distributed under the Licence is
 * distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied.
 * See the Licence for the specific language governing
 * permissions and limitations under the Licence.
 */
#include "MQ/Web/AuthenticationInformationMapper.h"
#include "MQ/Web/Dictionary.h"
#include "MQ/MQException.h"

namespace MQ {
namespace Web {

AuthenticationInformationMapper::AuthenticationInformationMapper(CommandServer& commandServer) : MQMapper(commandServer, "AuthenticationInformation")
{
}

AuthenticationInformationMapper::~AuthenticationInformationMapper()
{
}


void AuthenticationInformationMapper::change(const Poco::JSON::Object::Ptr&obj)
{
	poco_assert_dbg(false); // Not yet implemented
}


void AuthenticationInformationMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace)
{
	poco_assert_dbg(false); // Not yet implemented
}


void AuthenticationInformationMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace)
{
	poco_assert_dbg(false); // Not yet implemented
}


Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire(const Poco::JSON::Object::Ptr& filter)
{
	poco_assert_dbg(!filter.isNull());

	Poco::JSON::Array::Ptr jsonAuthInfos = new Poco::JSON::Array();

	PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_Q);
	command->addParameter(MQCA_AUTH_INFO_NAME, filter->optValue<std::string>("authInfoName", "*"));

	PCF::Vector commandResponse;
	_commandServer.sendCommand(command, commandResponse);

	bool excludeSystem = filter->optValue("excludeSystem", false);
	bool excludeTemp = filter->optValue("excludeTemp", false);

	for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++)
	{
		if ( (*it)->isExtendedResponse() ) // Skip extended response
			continue;

		if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example)
			continue;

		std::string qName = (*it)->getParameterString(MQCA_AUTH_INFO_NAME);
		if ( excludeSystem
			&& qName.compare(0, 7, "SYSTEM.") == 0 )
		{
			continue;
		}

		Poco::JSON::Object::Ptr jsonAuthInfo = new Poco::JSON::Object();
		jsonAuthInfos->add(jsonAuthInfo);

		dictionary()->mapToJSON(**it, jsonAuthInfo);
	}

	return jsonAuthInfos;
}

}} //  Namespace MQ::Web<commit_msg>Use correct command<commit_after>/*
 * Copyright 2010 MQWeb - <NAME>
 *
 * Licensed under the EUPL, Version 1.1 or ? as soon they
 * will be approved by the European Commission - subsequent
 * versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the
 * Licence.
 * You may obtain a copy of the Licence at:
 *
 * http://joinup.ec.europa.eu/software/page/eupl
 *
 * Unless required by applicable law or agreed to in
 * writing, software distributed under the Licence is
 * distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied.
 * See the Licence for the specific language governing
 * permissions and limitations under the Licence.
 */
#include "MQ/Web/AuthenticationInformationMapper.h"
#include "MQ/Web/Dictionary.h"
#include "MQ/MQException.h"

namespace MQ {
namespace Web {

AuthenticationInformationMapper::AuthenticationInformationMapper(CommandServer& commandServer) : MQMapper(commandServer, "AuthenticationInformation")
{
}

AuthenticationInformationMapper::~AuthenticationInformationMapper()
{
}


void AuthenticationInformationMapper::change(const Poco::JSON::Object::Ptr&obj)
{
	poco_assert_dbg(false); // Not yet implemented
}


void AuthenticationInformationMapper::create(const Poco::JSON::Object::Ptr& obj, bool replace)
{
	poco_assert_dbg(false); // Not yet implemented
}


void AuthenticationInformationMapper::copy(const Poco::JSON::Object::Ptr& obj, bool replace)
{
	poco_assert_dbg(false); // Not yet implemented
}


Poco::JSON::Array::Ptr AuthenticationInformationMapper::inquire(const Poco::JSON::Object::Ptr& filter)
{
	poco_assert_dbg(!filter.isNull());

	Poco::JSON::Array::Ptr jsonAuthInfos = new Poco::JSON::Array();

	PCF::Ptr command = _commandServer.createCommand(MQCMD_INQUIRE_AUTH_INFO);
	command->addParameter(MQCA_AUTH_INFO_NAME, filter->optValue<std::string>("authInfoName", "*"));

	PCF::Vector commandResponse;
	_commandServer.sendCommand(command, commandResponse);

	bool excludeSystem = filter->optValue("excludeSystem", false);

	for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++)
	{
		if ( (*it)->isExtendedResponse() ) // Skip extended response
			continue;

		if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example)
			continue;

		std::string qName = (*it)->getParameterString(MQCA_AUTH_INFO_NAME);
		if ( excludeSystem
			&& qName.compare(0, 7, "SYSTEM.") == 0 )
		{
			continue;
		}

		Poco::JSON::Object::Ptr jsonAuthInfo = new Poco::JSON::Object();
		jsonAuthInfos->add(jsonAuthInfo);

		dictionary()->mapToJSON(**it, jsonAuthInfo);
	}

	return jsonAuthInfos;
}

}} //  Namespace MQ::Web
{'fraction_non_alphanumeric': 0.12866032210834552, 'fraction_numerical': 0.004758418740849195, 'mean_word_length': 5.632281553398058, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2484805', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1602, 'n_words': 417}