DRDE/ACTK1_0/OTE/OteLPECreateCommand.cpp

133 lines
4.5 KiB
C++

#include "OTE/OteLPECreateCommand.hpp"
#include "xml/XMLHelper.hpp"
#include "OTE/OteExtension.hpp"
#include "common/ErrorPkg.hpp"
namespace {
Extension& oteExtension() {
static Extension* oteExtension = new OteExtension();
return *oteExtension;
}
}; // anonymous namespace
OteLPECreateCommand::OteLPECreateCommand (
const std::string& name,
const std::string& pw,
const std::string* registrantID,
const std::vector<std::string>* techContacts,
const std::string &oteEligibilityType,
int otePolicyReason,
const std::string &oteRegistrantName) : LPECreateCommand (
name, pw, registrantID, techContacts)
{
setExtension (oteEligibilityType, otePolicyReason, oteRegistrantName);
}
OteLPECreateCommand::OteLPECreateCommand (
const std::string& name,
const std::string& pw,
const std::string* registrantID,
const std::vector<std::string>* techContacts,
const std::vector<std::string>* adminContacts,
const std::vector<std::string>* billingContacts,
const std::vector<std::string>* nameservers,
const Period* period,
const std::string &oteEligibilityType,
int otePolicyReason,
const std::string &oteRegistrantName,
const std::string *oteRegistrantID,
const std::string *oteRegistrantIDType,
const std::string *oteEligibilityName,
const std::string *oteEligibilityID,
const std::string *oteEligibilityIDType) : LPECreateCommand (
name, pw, registrantID, techContacts, nameservers,
adminContacts, billingContacts, period)
{
setExtension (oteEligibilityType, otePolicyReason,
oteRegistrantName, oteRegistrantID, oteRegistrantIDType,
oteEligibilityName, oteEligibilityID, oteEligibilityIDType);
}
void OteLPECreateCommand::setExtension (const std::string& eligibilityType,
int policyReason,
const std::string& registrantName)
{
setExtension (eligibilityType, policyReason, registrantName,
NULL, NULL, NULL, NULL, NULL);
}
void OteLPECreateCommand::setExtension (
const std::string& eligibilityType,
int policyReason,
const std::string &registrantName,
const std::string* registrantID,
const std::string &registrantIDType)
{
setExtension (eligibilityType, policyReason, registrantName,
registrantID, &registrantIDType, NULL, NULL, NULL);
}
void OteLPECreateCommand::setExtension (
const std::string& eligibilityType,
int policyReason,
const std::string& registrantName,
const std::string* registrantID,
const std::string* registrantIDType,
const std::string* eligibilityName,
const std::string* eligibilityID,
const std::string* eligibilityIDType)
{
if ((registrantID && registrantIDType == NULL)
|| (registrantID == NULL && registrantIDType)
|| (eligibilityID && eligibilityIDType == NULL)
|| (eligibilityID == NULL && eligibilityIDType))
{
throw IllegalArgException(ErrorPkg::getMessage(
"se.domaincreate.ote.missing_ar"));
}
DOMElement *oteextCreate = xmlWriter->appendChild(
xmlWriter->appendChild(
command,
"extension"),
"create",
oteExtension().getURI());
XMLHelper::setAttribute(oteextCreate,
"xsi:schemaLocation",
oteExtension().getSchemaLocation());
DOMElement* oteProperties = xmlWriter->appendChild(
oteextCreate, "oteProperties");
XMLHelper::setTextContent(
xmlWriter->appendChild(oteProperties, "registrantName"),
registrantName);
if (registrantID && registrantIDType)
xmlWriter->appendChild (oteProperties,
"registrantID", *registrantID,
"type", *registrantIDType);
XMLHelper::setTextContent(
xmlWriter->appendChild(oteProperties, "eligibilityType"),
eligibilityType);
if (eligibilityName)
{
XMLHelper::setTextContent(
xmlWriter->appendChild(oteProperties, "eligibilityName"),
*eligibilityName);
if (eligibilityID && eligibilityIDType)
xmlWriter->appendChild(oteProperties,
"eligibilityID", *eligibilityID,
"type", *eligibilityIDType);
}
XMLHelper::setTextContent(
xmlWriter->appendChild(oteProperties, "policyReason"),
policyReason);
}