DRDE/ACTK1_0/OTE/OteLPECreateCommand.cpp

133 lines
4.5 KiB
C++
Raw Normal View History

2014-01-15 21:41:16 +00:00
#include "OTE/OteLPECreateCommand.hpp"
2014-01-15 18:29:15 +00:00
#include "xml/XMLHelper.hpp"
2014-01-15 21:41:16 +00:00
#include "OTE/OteExtension.hpp"
2014-01-15 18:29:15 +00:00
#include "common/ErrorPkg.hpp"
namespace {
2014-01-15 21:41:16 +00:00
Extension& oteExtension() {
static Extension* oteExtension = new OteExtension();
return *oteExtension;
2014-01-15 18:29:15 +00:00
}
}; // anonymous namespace
OteLPECreateCommand::OteLPECreateCommand (
const std::string& name,
const std::string& pw,
const std::string* registrantID,
const std::vector<std::string>* techContacts,
2014-01-15 21:41:16 +00:00
const std::string &oteEligibilityType,
int otePolicyReason,
const std::string &oteRegistrantName) : LPECreateCommand (
2014-01-15 18:29:15 +00:00
name, pw, registrantID, techContacts)
{
2014-01-15 21:41:16 +00:00
setExtension (oteEligibilityType, otePolicyReason, oteRegistrantName);
2014-01-15 18:29:15 +00:00
}
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,
2014-01-15 21:41:16 +00:00
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 (
2014-01-15 18:29:15 +00:00
name, pw, registrantID, techContacts, nameservers,
adminContacts, billingContacts, period)
{
2014-01-15 21:41:16 +00:00
setExtension (oteEligibilityType, otePolicyReason,
oteRegistrantName, oteRegistrantID, oteRegistrantIDType,
oteEligibilityName, oteEligibilityID, oteEligibilityIDType);
2014-01-15 18:29:15 +00:00
}
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(
2014-01-15 21:41:16 +00:00
"se.domaincreate.ote.missing_ar"));
2014-01-15 18:29:15 +00:00
}
2014-01-15 21:41:16 +00:00
DOMElement *oteextCreate = xmlWriter->appendChild(
2014-01-15 18:29:15 +00:00
xmlWriter->appendChild(
command,
"extension"),
"create",
2014-01-15 21:41:16 +00:00
oteExtension().getURI());
2014-01-15 18:29:15 +00:00
2014-01-15 21:41:16 +00:00
XMLHelper::setAttribute(oteextCreate,
2014-01-15 18:29:15 +00:00
"xsi:schemaLocation",
2014-01-15 21:41:16 +00:00
oteExtension().getSchemaLocation());
2014-01-15 18:29:15 +00:00
2014-01-15 21:41:16 +00:00
DOMElement* oteProperties = xmlWriter->appendChild(
oteextCreate, "oteProperties");
2014-01-15 18:29:15 +00:00
XMLHelper::setTextContent(
2014-01-15 21:41:16 +00:00
xmlWriter->appendChild(oteProperties, "registrantName"),
2014-01-15 18:29:15 +00:00
registrantName);
if (registrantID && registrantIDType)
2014-01-15 21:41:16 +00:00
xmlWriter->appendChild (oteProperties,
2014-01-15 18:29:15 +00:00
"registrantID", *registrantID,
"type", *registrantIDType);
XMLHelper::setTextContent(
2014-01-15 21:41:16 +00:00
xmlWriter->appendChild(oteProperties, "eligibilityType"),
2014-01-15 18:29:15 +00:00
eligibilityType);
if (eligibilityName)
{
XMLHelper::setTextContent(
2014-01-15 21:41:16 +00:00
xmlWriter->appendChild(oteProperties, "eligibilityName"),
2014-01-15 18:29:15 +00:00
*eligibilityName);
if (eligibilityID && eligibilityIDType)
2014-01-15 21:41:16 +00:00
xmlWriter->appendChild(oteProperties,
2014-01-15 18:29:15 +00:00
"eligibilityID", *eligibilityID,
"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);
}