DRDE/ACTK1_0/OTE/OteDomainTransferRegistrant...

93 lines
3.2 KiB
C++
Raw Normal View History

2014-01-15 18:29:15 +00:00
#include "se/XMLGregorianCalendar.hpp"
#include "se/CommandType.hpp"
#include "common/ErrorPkg.hpp"
2014-01-17 01:46:48 +00:00
#include "se/Period.hpp"
#include "se/RegistrantTransferCommandType.hpp"
#include "OTE/OteExtension.hpp"
#include "OTE/OteDomainObjectType.hpp"
#include "OTE/OteDomainTransferRegistrantCommand.hpp"
2014-01-15 18:29:15 +00:00
#include "se/EPPDateFormatter.hpp"
#include "xml/XMLHelper.hpp"
namespace {
2014-01-15 21:41:16 +00:00
Extension& oteExtension() {
static Extension* oteExt = new OteExtension();
return *oteExt;
2014-01-15 18:29:15 +00:00
}
const RegistrantTransferCommandType rtrnType;
2014-01-15 21:41:16 +00:00
OteDomainObjectType otedomType;
2014-01-15 18:29:15 +00:00
} // anonymous namespace
OteDomainTransferRegistrantCommand::OteDomainTransferRegistrantCommand (
const std::string& name,
const XMLGregorianCalendar& curExpDate,
const std::string& eligibilityType,
int policyReason,
const std::string& registrantName,
const std::string& explanation,
const std::string* registrantID,
const std::string* registrantIDType,
const std::string* eligibilityName,
const std::string* eligibilityID,
const std::string* eligibilityIDType,
const Period* period) : ProtocolExtensionCommand(
2014-01-15 21:41:16 +00:00
&rtrnType, &otedomType, name, oteExtension())
2014-01-15 18:29:15 +00:00
{
if ((registrantID && registrantIDType == NULL)
|| (registrantIDType == NULL && registrantIDType)
|| (eligibilityName && (eligibilityID == NULL || eligibilityIDType == NULL))
|| (eligibilityName == NULL && (eligibilityID || eligibilityIDType)))
{
// If provided, a registrantID must have a type.
// If provided, an eligibilityName must have both an eligibilityID and type.
throw IllegalArgException(
2014-01-15 21:41:16 +00:00
ErrorPkg::getMessage("se.domain.registrantTransfer.ote.missing_arg"));
2014-01-15 18:29:15 +00:00
}
DOMElement *element;
std::string curExpDateStr = EPPDateFormatter::toXSDate(curExpDate);
XMLHelper::setTextContent(
xmlWriter->appendChild(objElement, "curExpDate"), curExpDateStr);
if (period)
period->appendPeriod(xmlWriter, objElement);
2014-01-15 21:41:16 +00:00
DOMElement *oteProperties = xmlWriter->appendChild(objElement, "oteProperties");
2014-01-15 18:29:15 +00:00
XMLHelper::setTextContent(
2014-01-15 21:41:16 +00:00
xmlWriter->appendChild(oteProperties, "registrantName"), registrantName);
2014-01-15 18:29:15 +00:00
if (registrantID)
{
2014-01-15 21:41:16 +00:00
element = xmlWriter->appendChild(oteProperties, "registrantID");
2014-01-15 18:29:15 +00:00
XMLHelper::setTextContent(element, *registrantID);
XMLHelper::setAttribute(element, "type", *registrantIDType);
}
XMLHelper::setTextContent
2014-01-15 21:41:16 +00:00
(xmlWriter->appendChild(oteProperties, "eligibilityType"), eligibilityType);
2014-01-15 18:29:15 +00:00
if (eligibilityName)
{
XMLHelper::setTextContent(
2014-01-15 21:41:16 +00:00
xmlWriter->appendChild(oteProperties, "eligibilityName"), *eligibilityName);
2014-01-15 18:29:15 +00:00
2014-01-15 21:41:16 +00:00
element = xmlWriter->appendChild(oteProperties, "eligibilityID");
2014-01-15 18:29:15 +00:00
XMLHelper::setTextContent(element, *eligibilityID);
XMLHelper::setAttribute(element, "type", *eligibilityIDType);
}
XMLHelper::setTextContent(
2014-01-15 21:41:16 +00:00
xmlWriter->appendChild(oteProperties, "policyReason"),
2014-01-15 18:29:15 +00:00
policyReason);
XMLHelper::setTextContent(
xmlWriter->appendChild(objElement, "explanation"),
explanation);
}