1 /*
2 * Copyright (C) 2006-2021 Registro.br. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * 1. Redistribution of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16 * EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
19 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
21 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
22 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23 * DAMAGE.
24 */
25 /* $Id$ */
26
27 #include "DomainDelete.H"
28 #include "StrUtil.H"
29
30 LIBEPP_NICBR_NS_BEGIN
31
fill_launch_output(DomainDeleteCmd * cmd)32 string fill_launch_output(DomainDeleteCmd *cmd)
33 {
34 string output("");
35
36 LaunchDeleteCmd launch = cmd->get_launch();
37 if (launch.get_phase().get_phase() == LaunchPhase::NONE) {
38 return output;
39 }
40
41 StrUtil su;
42
43 output += "<launch:delete xmlns:launch=\"urn:ietf:params:xml:ns:launch-1.0\">"
44 "<launch:phase";
45
46 LaunchPhase phase = launch.get_phase();
47 if (!phase.get_name().empty()) {
48 output += " name=\"" + su.esc_xml_markup(phase.get_name()) + "\"";
49 }
50
51 output += ">" + LaunchPhase::toStr(phase.get_phase()) + "</launch:phase>"
52 "<launch:applicationID>" + su.esc_xml_markup(launch.get_applicationId()) +
53 "</launch:applicationID>"
54 "</launch:delete>";
55 return output;
56 }
57
set_xml_template(const string & xml_template)58 void DomainDelete::set_xml_template(const string &xml_template)
59 {
60 StrUtil su;
61 Action::set_xml_template_common(xml_template);
62 map < string, string, less<string> > to_parse;
63
64 //name
65 to_parse["name"] = su.esc_xml_markup(get_command()->get_name());
66
67 to_parse["ext_begin"] = "";
68 to_parse["ext_end"] = "";
69 to_parse["launch_ext"] = "";
70
71 if (get_command()->has_extension()) {
72 to_parse["ext_begin"] = "<extension>";
73 to_parse["ext_end"] = "</extension>";
74 to_parse["launch_ext"] = fill_launch_output(get_command());
75 }
76
77 _xml = StrUtil::parse(_xml, to_parse, "$(", ")$");
78 }
79
80 LIBEPP_NICBR_NS_END
81