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 /** @file BrDomainUpdateCmd.H
27  *  @brief EPP BrDomainUpdateCmd extension Class
28  */
29 
30 #ifndef __BR_DOMAIN_UPDATE_CMD_H__
31 #define __BR_DOMAIN_UPDATE_CMD_H__
32 
33 #include "BrDomainCommon.H"
34 #include "DomainUpdateCmd.H"
35 
36 LIBEPP_NICBR_NS_BEGIN
37 
38 /// EPP BrDomainUpdateCmd extension Class
39 class BrDomainUpdateCmd : public DomainUpdateCmd
40 {
41 public:
42 	enum PublicationStatus {
43 		UNDEFINED,
44 		PUBLISHED,
45 		ONHOLD
46 	};
47 
48 	/// Default constructor
DomainUpdateCmd(false)49 	BrDomainUpdateCmd(bool reset = true) : DomainUpdateCmd(false)
50 	{
51 		if (reset) {
52 			this->reset();
53 		}
54 	}
55 
56 	/// Sets ticket number
57 	/**
58 	   @param ticketNumber   ticket number
59 	*/
set_ticketNumber(const int ticketNumber)60 	void set_ticketNumber(const int ticketNumber)
61 	{
62 		_ticketNumber = ticketNumber;
63 	}
64 
65 	/// Returns ticket number
66 	/**
67 	   @return ticket number
68 	*/
get_ticketNumber()69 	int get_ticketNumber() const
70 	{
71 		return _ticketNumber;
72 	}
73 
74 	/// Sets the Release Process Flags
75 	/**
76 	   @param rpf Release Process Flags
77 	*/
set_releaseProcessFlags(const struct ReleaseProcessFlags & rpf)78 	void set_releaseProcessFlags(const struct ReleaseProcessFlags& rpf)
79 	{
80 		_releaseProcessFlags.flag1 = rpf.flag1;
81 		_releaseProcessFlags.flag2 = rpf.flag2;
82 		_releaseProcessFlags.flag3 = rpf.flag3;
83 	}
84 
85 	/// Returns the Release Process Flags
86 	/**
87 	   @return Release Process Flags
88 	*/
get_releaseProcessFlags()89 	struct ReleaseProcessFlags get_releaseProcessFlags() const
90 	{
91 		return _releaseProcessFlags;
92 	}
93 
94 	///  Actives/Inactives domain auto renewal
95 	/**
96 	   @param auto_renew attribute
97 	*/
set_auto_renew(const int auto_renew)98 	void set_auto_renew(const int auto_renew)
99 	{
100 		_auto_renew = auto_renew;
101 	}
102 
103 	///  Return if the domain is with or without auto renewal
104 	/**
105 	   @return auto_renew attribute
106 	*/
get_auto_renew()107 	int get_auto_renew() const
108 	{
109 		return _auto_renew;
110 	}
111 
112 	/// Sets domain publication status
113 	/**
114 	   @param status domain publication status
115 	*/
set_publication_status(const PublicationStatus status)116 	void set_publication_status(const PublicationStatus status)
117 	{
118 		_publication_status = status;
119 	}
120 
121 	/// Returns domain publication status
122 	/**
123 	   @return domain publication status
124 	*/
get_publication_status()125 	PublicationStatus get_publication_status() const
126 	{
127 		return _publication_status;
128 	}
129 
130 	/// Sets domain's organization
131 	/**
132 	   @param organization Organization identifier
133 	*/
set_organization(const string & organization)134 	void set_organization(const string &organization)
135 	{
136 		_organization = organization;
137 	}
138 
139 	/// Returns domain's organization
140 	/**
141 	   @return Organization identifier
142 	*/
get_organization()143 	string get_organization() const
144 	{
145 		return _organization;
146 	}
147 
148 	/// Reset object attributes
reset()149 	void reset()
150 	{
151 		DomainUpdateCmd::reset();
152 		_ticketNumber = 0;
153 		_releaseProcessFlags.flag1 = -1;
154 		_releaseProcessFlags.flag2 = -1;
155 		_releaseProcessFlags.flag3 = -1;
156 		_auto_renew = -1;
157 		_publication_status = UNDEFINED;
158 		_organization = "";
159 	}
160 
161 	///  Sets active attribute (***DEPRECATED***)
162 	/**
163 	   @param active attribute
164 	*/
set_active(int active)165 	void set_active(int active)
166 	{
167 		set_auto_renew(active);
168 	}
169 
170 	/// Returns active attribute (***DEPRECATED***)
171 	/**
172 	   @return active attribute
173 	*/
get_active()174 	int get_active()
175 	{
176 		return get_auto_renew();
177 	}
178 
179 	/// Check if there is any extension
has_extension()180 	bool has_extension() {
181 		return (DomainUpdateCmd::has_extension() || has_br_extension());
182 	}
183 
184 	/// Check if there is BR extension
has_br_extension()185 	bool has_br_extension() {
186 		return (_ticketNumber > 0 ||
187 		        _auto_renew == 0 || _auto_renew == 1 ||
188 		        _publication_status != UNDEFINED ||
189 		        _organization.empty() == false);
190 	}
191 
192 protected:
193 	/// ticket number
194 	int _ticketNumber;
195 
196 	/// release process flags
197 	struct ReleaseProcessFlags _releaseProcessFlags;
198 
199 	/// domain auto renewal flag
200 	int _auto_renew;
201 
202 	/// domain status flag
203 	PublicationStatus _publication_status;
204 
205 	/// Domain organization
206 	string _organization;
207 };
208 
209 LIBEPP_NICBR_NS_END
210 #endif //__BR_DOMAIN_UPDATE_CMD_H__
211