DRDE/ACTK1_0/OTE/OteDomainTransferRegistrant...

93 lines
3.2 KiB
C++

#include "OTE/OteDomainTransferRegistrantCommand.hpp"
#include "se/XMLGregorianCalendar.hpp"
#include "OTE/OteExtension.hpp"
#include "OTE/OteDomainObjectType.hpp"
#include "se/RegistrantTransferCommandType.hpp"
#include "se/CommandType.hpp"
#include "se/Period.hpp"
#include "common/ErrorPkg.hpp"
#include "se/EPPDateFormatter.hpp"
#include "xml/XMLHelper.hpp"
namespace {
Extension& oteExtension() {
static Extension* oteExt = new OteExtension();
return *oteExt;
}
const RegistrantTransferCommandType rtrnType;
OteDomainObjectType otedomType;
} // 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(
&rtrnType, &otedomType, name, oteExtension())
{
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(
ErrorPkg::getMessage("se.domain.registrantTransfer.ote.missing_arg"));
}
DOMElement *element;
std::string curExpDateStr = EPPDateFormatter::toXSDate(curExpDate);
XMLHelper::setTextContent(
xmlWriter->appendChild(objElement, "curExpDate"), curExpDateStr);
if (period)
period->appendPeriod(xmlWriter, objElement);
DOMElement *oteProperties = xmlWriter->appendChild(objElement, "oteProperties");
XMLHelper::setTextContent(
xmlWriter->appendChild(oteProperties, "registrantName"), registrantName);
if (registrantID)
{
element = xmlWriter->appendChild(oteProperties, "registrantID");
XMLHelper::setTextContent(element, *registrantID);
XMLHelper::setAttribute(element, "type", *registrantIDType);
}
XMLHelper::setTextContent
(xmlWriter->appendChild(oteProperties, "eligibilityType"), eligibilityType);
if (eligibilityName)
{
XMLHelper::setTextContent(
xmlWriter->appendChild(oteProperties, "eligibilityName"), *eligibilityName);
element = xmlWriter->appendChild(oteProperties, "eligibilityID");
XMLHelper::setTextContent(element, *eligibilityID);
XMLHelper::setAttribute(element, "type", *eligibilityIDType);
}
XMLHelper::setTextContent(
xmlWriter->appendChild(oteProperties, "policyReason"),
policyReason);
XMLHelper::setTextContent(
xmlWriter->appendChild(objElement, "explanation"),
explanation);
}