libepp_nicbr
BrOrgFunctions.H
Go to the documentation of this file.
1 /* ${copyright}$ */
2 /* $Id: BrOrgFunctions.H 1256 2014-12-01 13:02:14Z rafael $ */
6 #ifndef __BRORG_FUNCTIONS_H__
7 #define __BRORG_FUNCTIONS_H__
9 
10 #include "BrOrgCheck.H"
11 #include "BrOrgInfo.H"
12 #include "BrOrgCreate.H"
13 #include "BrOrgUpdate.H"
14 #include "BrOrgDelete.H"
15 
17 
22 int cmd_brorg_help(string error_msg, string specific = "")
23 {
24  if (error_msg != "") {
25  printf("error: %s\n", error_msg.c_str());
26  }
27 
28  printf("brorg command syntax help:\n");
29  printf("\n");
30 
31  if (specific == "" || specific == "check") {
32  printf(" check <brorg1> [brorg2 ... brorgN]\n");
33  printf("\n");
34  }
35  if (specific == "" || specific == "info") {
36  printf(" info <brorg> [-auth authInfoPw]\n");
37  printf("\n");
38  }
39  if (specific == "" || specific == "transfer") {
40  printf(" transfer: not implemented\n");
41  printf("\n");
42  }
43  if (specific == "" || specific == "create") {
44  printf(" create <brorg>\n");
45  printf(" [-postalInfo <type> <-name \"BrOrg Name\"> "
46  "[-org \"Org Name\"]\n");
47  printf(" <-street1 \"address street/line 1\"> "
48  "[-street2 \"address number/line 2\"]\n");
49  printf(" [-street3 \"address line 3\"] <-city \"City Name\"> "
50  "[-state \"State or Province\"]\n");
51  printf(" [-pc \"postal code\"] <-cc country-code> ...]\n");
52  printf(" <-voice number:ext> [-fax number:ext]\n");
53  printf(" <-email emailAddr> [-auth authInfoPw]\n");
54  printf(" [-disclose opt,opt,...] "
55  " [-responsible \"Responsible Name\"]\n"
56  " -contact key=value[,key=value,...]\n"
57  " [-type \"value\"] [-epp-password \"password\"] "
58  "[-epp-ip \"ip\" ...]\n"
59  " [-renewal-type type ...] [-resources-class class]\n");
60  printf("\n");
61  printf(" available values for opt:\n");
62  printf(" {name_int name_loc org_int org_loc addr_int addr_loc "
63  "voice fax email}\n");
64  printf("\n");
65  }
66  if (specific == "" || specific == "delete") {
67  printf(" delete <brorg>\n");
68  printf("\n");
69  }
70  if (specific == "" || specific == "renew") {
71  printf(" renew: not implemented\n");
72  printf("\n");
73  }
74  if (specific == "" || specific == "update") {
75  printf(" update <brorg> [-add-status st1,...,stN] "
76  "[-rem-status st1,...,stN]\n");
77  printf(" [-postalInfo <type> [-name \"BrOrg Name\"] "
78  "[-org \"Org Name\"]\n");
79  printf(" [-street1 \"address street/line 1\"] "
80  "[-street2 \"address number/line 2\"]\n");
81  printf(" [-street3 \"address line 3\"] [-city \"City Name\"] "
82  "[-state \"State or Province\"]\n");
83  printf(" [-pc \"postal code\"] [-cc country-code] ...]\n");
84  printf(" [-voice number:ext] [-fax number:ext]\n");
85  printf(" [-email emailAddr] [-auth authInfoPw] "
86  "[-disclose opt,opt,...]\n");
87  printf(" [-responsible \"Responsible Name\"]\n");
88  printf(" [-exdate expirationDate]\n");
89  printf(" [-add-contact key=value[,key=value,...]\n");
90  printf(" [-rem-contact key=value[,key=value,...]\n");
91  printf(" [-suspended <true|false>]\n"
92  " [-type \"value\"] [-epp-status <active|blocked>]\n"
93  " [-epp-password \"password\"]\n"
94  " [-epp-ip-add \"ip\" ...] [-epp-ip-rem \"ip\" ...]\n"
95  " [-renewal-type-add type ...] [-renewal-type-rem type ...]\n"
96  " [-resources-class class] [-password \"password\"]\n");
97  printf("\n");
98  printf(" available values for opt:\n");
99  printf(" {name_int name_loc org_int org_loc addr_int addr_loc "
100  "voice fax email}\n");
101  printf("\n");
102  }
103 
104  if (error_msg != "") {
105  return -1;
106  }
107 
108  return 0;
109 }
110 
112 
116 int cmd_brorg_check(vector<string> &args)
117 {
118  BrOrgCheck act;
119  BrOrgCheckCmd *cmd = act.get_command();
120  string cmd_name = "check";
121 
122  string id;
123  int counter = 0;
124  while (!args.empty()) {
125  string numbers = SheppStrUtil::doc2id(args[0]);
126  cmd->insert_id(numbers);
127  cmd->insert_organization(numbers, args[0]);
128  args.erase(args.begin());
129  counter++;
130  }
131 
132  if (cmd->get_id_list().empty() || cmd->get_organization_list().empty()) {
133  return cmd_brorg_help("no brorg specified", cmd_name);
134  }
135 
136  if (_debug) {
137  map<string, string, less<string> > brorgs = cmd->get_organization_list();
138  map<string, string, less<string> >::const_iterator it;
139  printf("brorgs to be checked:\n");
140  for (it = brorgs.begin(); it != brorgs.end(); it++) {
141  printf(" id: [%s] org: [%s]\n", (*it).first.c_str(),
142  (*it).second.c_str());
143  }
144  } // _debug
145 
146  if (process_action(act) != 0) {
147  return -1;
148  }
149 
150  return 0;
151 }
152 
154 
158 int cmd_brorg_info(vector<string> &args)
159 {
160  BrOrgInfo act;
161  BrOrgInfoCmd *cmd = act.get_command();
162  string cmd_name = "info";
163 
164  if (args.empty()) {
165  return cmd_brorg_help("no brorg specified", cmd_name);
166  }
167 
168  cmd->set_id(SheppStrUtil::doc2id(args[0]));
169  cmd->set_organization(args[0]);
170  args.erase(args.begin());
171 
172  while (!args.empty()) {
173  if (args[0] == "-auth") {
174  //set authInfo
175  AuthInfo auth;
176  if (SheppObjSet::authInfo(auth, args) != 0) {
177  return cmd_brorg_help("invalid auth", cmd_name);
178  }
179 
180  // roid not allowed in brorg commands
181  if (auth.get_roid_f() == true) {
182  return cmd_contact_help("invalid auth", cmd_name);
183  }
184 
185  cmd->set_authInfo(auth);
186  } else {
187  return cmd_brorg_help("invalid syntax near \"" + args[0] + "\"",
188  cmd_name);
189  }
190 
191  }
192 
193  if (_debug) {
194  printf("id to get info: [%s]\n", cmd->get_id().c_str());
195  printf("org to get info: [%s]\n", cmd->get_organization().c_str());
197  } // _debug
198 
199  if (process_action(act) != 0) {
200  return -1;
201  }
202 
203  return 0;
204 }
205 
207 
211 int cmd_brorg_transfer(vector<string> &args)
212 {
213  string cmd_name = "transfer";
214  return cmd_brorg_help("", cmd_name);
215 }
216 
218 
222 int cmd_brorg_create(vector<string> &args)
223 {
224  BrOrgCreate act;
225  BrOrgCreateCmd *cmd = act.get_command();
226  string cmd_name = "create";
227 
228  if (args.empty()) {
229  return cmd_brorg_help("no brorg specified", cmd_name);
230  }
231 
232  CommonData common_data;
233 
234  common_data.set_id(SheppStrUtil::doc2id(args[0]));
235  cmd->set_organization(args[0]);
236 
237  args.erase(args.begin());
238 
239  //authInfo defaults to empty
240  AuthInfo auth;
241  cmd->set_authInfo(auth);
242 
243  while (!args.empty()) {
244  if (args[0] == "-postalInfo") {
245  //postalInfo
246  args.erase(args.begin());
247  if (args.empty()) {
248  return cmd_brorg_help("missing postal info arguments", cmd_name);
249  }
250  PostalInfo postal;
251  string error_msg;
252  if (SheppObjSet::postalInfo(postal, args, error_msg, false) != 0) {
253  return cmd_brorg_help(error_msg, cmd_name);
254  }
255  vector<PostalInfo> postal_list = common_data.get_postal_info();
256  for (int i = 0; i < (int) postal_list.size(); i++) {
257  if (postal_list[i].get_type() == postal.get_type()) {
258  return cmd_brorg_help("duplicated postal info type", cmd_name);
259  }
260  }
261  common_data.insert_postal_info(postal);
262  } else if (args[0] == "-voice") {
263  //voice
264  args.erase(args.begin());
265  CommonData::Phone phone;
266  if (SheppObjSet::phone(phone, args) != 0) {
267  return cmd_brorg_help("error setting voice telephone number",
268  cmd_name);
269  }
270  common_data.set_voice(phone);
271  } else if (args[0] == "-fax") {
272  //fax
273  args.erase(args.begin());
274  CommonData::Phone phone;
275  if (SheppObjSet::phone(phone, args) != 0) {
276  return cmd_brorg_help("error setting fax telephone number",
277  cmd_name);
278  }
279  common_data.set_fax(phone);
280  } else if (args[0] == "-email") {
281  //email
282  args.erase(args.begin());
283  if (args.empty()) {
284  return cmd_brorg_help("no e-mail address specified", cmd_name);
285  }
286  common_data.set_email(args[0]);
287  args.erase(args.begin());
288  } else if (args[0] == "-auth") {
289  //auth
290  AuthInfo auth;
291  if (SheppObjSet::authInfo(auth, args) != 0) {
292  return cmd_brorg_help("invalid auth", cmd_name);
293  }
294 
295  // roid not allowed in brorg commands
296  if (auth.get_roid_f() == true) {
297  return cmd_contact_help("invalid auth", cmd_name);
298  }
299 
300  cmd->set_authInfo(auth);
301  } else if (args[0] == "-disclose") {
302  //disclose
303  args.erase(args.begin());
304  CommonData::Disclose disclose;
305  if (SheppObjSet::disclose(disclose, args[0]) != 0) {
306  return cmd_brorg_help("invalid diclose information", cmd_name);
307  }
308  args.erase(args.begin());
309  common_data.set_disclose(disclose);
310  } else if (args[0] == "-contact") {
311  //contacts
312  args.erase(args.begin());
313  if (args.empty()) {
314  return cmd_brorg_help("-contact requires an argument", cmd_name);
315  }
316  map<string, string, less<string> > my_contacts;
317  string error_msg;
318  if (SheppObjSet::contacts(my_contacts, args[0], error_msg) != 0) {
319  return cmd_brorg_help(error_msg, cmd_name);
320  }
321  map<string, string, less<string> >::const_iterator it;
322  for (it = my_contacts.begin(); it != my_contacts.end(); it++) {
323  cmd->insert_contact((*it).first, (*it).second);
324  }
325  args.erase(args.begin());
326  } else if (args[0] == "-responsible") {
327  //responsible
328  args.erase(args.begin());
329  if (args.empty()) {
330  return cmd_brorg_help("unspecified responsible name", cmd_name);
331  }
332  string responsible_name = args[0];
333  args.erase(args.begin());
334  if (SheppStrUtil::quote_gathering(args, responsible_name) != 0) {
335  return cmd_brorg_help("error setting responsible name", cmd_name);
336  }
337  cmd->set_responsible(responsible_name);
338 
339  } else if (args[0] == "-type") {
340  //type
341  args.erase(args.begin());
342  if (args.empty()) {
343  return cmd_brorg_help("unspecified type", cmd_name);
344  }
345  string type = args[0];
346  args.erase(args.begin());
347  if (SheppStrUtil::quote_gathering(args, type) != 0) {
348  return cmd_brorg_help("error setting type", cmd_name);
349  }
350  cmd->set_type(type);
351 
352  } else if (args[0] == "-epp-password") {
353  //EPP password
354  args.erase(args.begin());
355  if (args.empty()) {
356  return cmd_brorg_help("unspecified EPP password", cmd_name);
357  }
358  string epp_password = args[0];
359  args.erase(args.begin());
360  if (SheppStrUtil::quote_gathering(args, epp_password) != 0) {
361  return cmd_brorg_help("error setting EPP password", cmd_name);
362  }
363  cmd->set_epp_password(epp_password);
364 
365  } else if (args[0] == "-epp-ip") {
366  //EPP IP or range
367  args.erase(args.begin());
368  if (args.empty()) {
369  return cmd_brorg_help("unspecified EPP IP", cmd_name);
370  }
371  string epp_ip = args[0];
372  args.erase(args.begin());
373  if (SheppStrUtil::quote_gathering(args, epp_ip) != 0) {
374  return cmd_brorg_help("error setting EPP IP", cmd_name);
375  }
376  cmd->insert_epp_ip(epp_ip);
377 
378  } else if (args[0] == "-renewal-type") {
379  //Renewal type
380  args.erase(args.begin());
381  if (args.empty()) {
382  return cmd_brorg_help("unspecified renewal type", cmd_name);
383  }
384  string renewal_type = args[0];
385  args.erase(args.begin());
386  if (SheppStrUtil::quote_gathering(args, renewal_type) != 0) {
387  return cmd_brorg_help("error setting renewal type", cmd_name);
388  }
389  cmd->insert_renewal_type(renewal_type);
390 
391  } else if (args[0] == "-resources-class") {
392  //Resources class
393  args.erase(args.begin());
394  if (args.empty()) {
395  return cmd_brorg_help("unspecified resources class", cmd_name);
396  }
397  string resources_class = args[0];
398  args.erase(args.begin());
399  if (SheppStrUtil::quote_gathering(args, resources_class) != 0) {
400  return cmd_brorg_help("error setting resources class", cmd_name);
401  }
402  cmd->set_resources_class(resources_class);
403 
404  } else {
405  return cmd_brorg_help("invalid syntax near \"" + args[0] + "\"",
406  cmd_name);
407  }
408  }
409 
410  if (common_data.get_postal_info().empty()) {
411  return cmd_brorg_help("at least one postal info must be entered",
412  cmd_name);
413  }
414 
415  if (common_data.get_email() == "") {
416  return cmd_brorg_help("e-mail is mandatory", cmd_name);
417  }
418 
419  if (common_data.get_voice().number == "") {
420  return cmd_brorg_help("voice telephone number is mandatory", cmd_name);
421  }
422 
423  if (cmd->get_organization() == "") {
424  return cmd_brorg_help("orgid unset", cmd_name);
425  }
426 
427  if (cmd->get_contact_list().empty()) {
428  return cmd_brorg_help("at least one contact must be entered", cmd_name);
429  }
430 
431  cmd->set_common_data(common_data);
432 
433  if (_debug) {
434  printf(" brorg: [%s]\n", cmd->get_common_data().get_id().c_str());
435 
436  vector<PostalInfo>::const_iterator it;
437  vector<PostalInfo> postal_list;
438  postal_list = cmd->get_common_data().get_postal_info();
439  for (it = postal_list.begin(); it != postal_list.end(); it++) {
441  }
442 
443  if (cmd->get_common_data().get_voice().number != "") {
444  printf(" voice:");
446  }
447 
448  if (cmd->get_common_data().get_fax().number != "") {
449  printf(" fax :");
451  }
452 
453  printf(" email: [%s]\n", cmd->get_common_data().get_email().c_str());
454 
456 
457  if (cmd->get_common_data().get_disclose().is_set()) {
459  }
460 
461  //brorg
462  printf(" orgid: [%s]\n", cmd->get_organization().c_str());
463 
464  map<string, string, less<string> > contacts = cmd->get_contact_list();
465  map<string, string, less<string> >::const_iterator c_it;
466  for (c_it = contacts.begin(); c_it != contacts.end(); c_it++) {
467  printf(" contact[%s] = [%s]\n", (*c_it).first.c_str(),
468  (*c_it).second.c_str());
469  }
470 
471  // lacnicorg
472  if (!cmd->get_type().empty()) {
473  printf(" type: %s\n", cmd->get_type().c_str());
474  }
475 
476  if (!cmd->get_epp_password().empty()) {
477  printf(" epp password: %s\n", cmd->get_epp_password().c_str());
478  }
479 
480  vector<string> epp_ips = cmd->get_epp_ips();
481  for (int i = 0; i < epp_ips.size(); i++) {
482  printf(" epp ip: %s\n", epp_ips[i].c_str());
483  }
484 
485  vector<string> renewal_types = cmd->get_renewal_types();
486  for (int i = 0; i < renewal_types.size(); i++) {
487  printf(" renewal type: %s\n", renewal_types[i].c_str());
488  }
489 
490  if (!cmd->get_resources_class().empty()) {
491  printf(" resources class: %s\n", cmd->get_resources_class().c_str());
492  }
493  } // _debug
494 
495  if (process_action(act) != 0) {
496  return -1;
497  }
498 
499  return 0;
500 }
501 
503 
507 int cmd_brorg_delete(vector<string> &args)
508 {
509  BrOrgDelete act;
510  BrOrgDeleteCmd *cmd = act.get_command();
511  string cmd_name = "delete";
512 
513  if (args.empty()) {
514  return cmd_brorg_help("no brorg specified", cmd_name);
515  }
516 
517  cmd->set_id(SheppStrUtil::doc2id(args[0]));
518  cmd->set_organization(args[0]);
519  args.erase(args.begin());
520 
521  if (process_action(act) != 0) {
522  return -1;
523  }
524 
525  return 0;
526 }
527 
529 
533 int cmd_brorg_renew(vector<string> &args)
534 {
535  string cmd_name = "renew";
536  return cmd_brorg_help("", cmd_name);
537 }
538 
540 
544 int cmd_brorg_update(vector<string> &args)
545 {
546  BrOrgUpdate act;
547  BrOrgUpdateCmd *cmd = act.get_command();
548  string cmd_name = "update";
549 
550  if (args.empty()) {
551  return cmd_brorg_help("no brorg specified", cmd_name);
552  }
553 
554  CommonData common_data;
555  common_data.set_id(SheppStrUtil::doc2id(args[0]));
556 
557  cmd->set_organization(args[0]);
558  args.erase(args.begin());
559 
560  while (!args.empty()) {
561  if (args[0] == "-add-status") {
562  //add-status
563  args.erase(args.begin());
564  if (args.empty()) {
565  return cmd_brorg_help("error setting add-status", cmd_name);
566  }
567  string tmp1 = args[0];
568  string tmp2;
569  while (SheppStrUtil::split(tmp1, tmp1, tmp2, ",", true) == 0) {
570  cmd->insert_status_list_add(tmp1);
571  if (tmp2 == "") {
572  break;
573  }
574  tmp1 = tmp2;
575  }
576  args.erase(args.begin());
577  } else if (args[0] == "-rem-status") {
578  //rem-status
579  args.erase(args.begin());
580  if (args.empty()) {
581  return cmd_brorg_help("error setting rem-status", cmd_name);
582  }
583  string tmp1 = args[0];
584  string tmp2;
585  while (SheppStrUtil::split(tmp1, tmp1, tmp2, ",", true) == 0) {
586  cmd->insert_status_list_rem(tmp1);
587  if (tmp2 == "") {
588  break;
589  }
590  tmp1 = tmp2;
591  }
592  args.erase(args.begin());
593  } else if (args[0] == "-postalInfo") {
594  //postalInfo
595  args.erase(args.begin());
596  if (args.empty()) {
597  return cmd_brorg_help("missing postal info arguments", cmd_name);
598  }
599  PostalInfo postal;
600  string error_msg;
601  if (SheppObjSet::postalInfo(postal, args, error_msg, true) != 0) {
602  return cmd_brorg_help(error_msg, cmd_name);
603  }
604  vector<PostalInfo> postal_list = common_data.get_postal_info();
605  for (int i = 0; i < (int) postal_list.size(); i++) {
606  if (postal_list[i].get_type() == postal.get_type()) {
607  return cmd_brorg_help("duplicated postal info type", cmd_name);
608  }
609  }
610  common_data.insert_postal_info(postal);
611  } else if (args[0] == "-voice") {
612  //voice
613  args.erase(args.begin());
614  CommonData::Phone phone;
615  if (SheppObjSet::phone(phone, args) != 0) {
616  return cmd_brorg_help("error setting voice telephone number",
617  cmd_name);
618  }
619  common_data.set_voice(phone);
620  } else if (args[0] == "-fax") {
621  //fax
622  args.erase(args.begin());
623  CommonData::Phone phone;
624  if (SheppObjSet::phone(phone, args) != 0) {
625  return cmd_brorg_help("error setting fax telephone number",
626  cmd_name);
627  }
628  common_data.set_fax(phone);
629  } else if (args[0] == "-email") {
630  //email
631  args.erase(args.begin());
632  if (args.empty()) {
633  return cmd_brorg_help("no e-mail address specified", cmd_name);
634  }
635  common_data.set_email(args[0]);
636  args.erase(args.begin());
637  } else if (args[0] == "-auth") {
638  //auth
639  AuthInfo auth;
640  if (SheppObjSet::authInfo(auth, args) != 0) {
641  return cmd_brorg_help("invalid auth", cmd_name);
642  }
643 
644  // roid not allowed in update command
645  if (auth.get_roid_f() == true) {
646  return cmd_brorg_help("invalid auth", cmd_name);
647  }
648 
649  cmd->set_authInfo(auth);
650  } else if (args[0] == "-disclose") {
651  //disclose
652  args.erase(args.begin());
653  CommonData::Disclose disclose;
654  if (SheppObjSet::disclose(disclose, args[0]) != 0) {
655  return cmd_brorg_help("invalid diclose information", cmd_name);
656  }
657  args.erase(args.begin());
658  common_data.set_disclose(disclose);
659  } else if (args[0] == "-add-contact") {
660  //add contacts
661  args.erase(args.begin());
662  if (args.empty()) {
663  return cmd_brorg_help("-add-contact requires an argument",
664  cmd_name);
665  }
666  map<string, string, less<string> > my_contacts;
667  string error_msg;
668  if (SheppObjSet::contacts(my_contacts, args[0], error_msg) != 0) {
669  return cmd_brorg_help(error_msg, cmd_name);
670  }
671  map<string, string, less<string> >::const_iterator it;
672  for (it = my_contacts.begin(); it != my_contacts.end(); it++) {
673  cmd->insert_contact_add((*it).first, (*it).second);
674  }
675  args.erase(args.begin());
676  } else if (args[0] == "-rem-contact") {
677  //remove contacts
678  args.erase(args.begin());
679  if (args.empty()) {
680  return cmd_brorg_help("-rem-contact requires an argument",
681  cmd_name);
682  }
683  map<string, string, less<string> > my_contacts;
684  string error_msg;
685  if (SheppObjSet::contacts(my_contacts, args[0], error_msg) != 0) {
686  return cmd_brorg_help(error_msg, cmd_name);
687  }
688  map<string, string, less<string> >::const_iterator it;
689  for (it = my_contacts.begin(); it != my_contacts.end(); it++) {
690  cmd->insert_contact_rem((*it).first, (*it).second);
691  }
692  args.erase(args.begin());
693 
694  } else if (args[0] == "-responsible") {
695  //responsible
696  args.erase(args.begin());
697  if (args.empty()) {
698  return cmd_brorg_help("unspecified responsible name", cmd_name);
699  }
700  string responsible_name = args[0];
701  args.erase(args.begin());
702  if (SheppStrUtil::quote_gathering(args, responsible_name) != 0) {
703  return cmd_brorg_help("error setting responsible name", cmd_name);
704  }
705  cmd->set_responsible(responsible_name);
706  } else if (args[0] == "-exdate") {
707  //expiration date
708  args.erase(args.begin());
709  if (args.empty()) {
710  return cmd_brorg_help("unspecified expiration date", cmd_name);
711  }
712  cmd->set_exDate(args[0]);
713  args.erase(args.begin());
714  } else if (args[0] == "-suspended") {
715  // suspended
716  args.erase(args.begin());
717  if (args.empty()) {
718  return cmd_brorg_help("unspecified suspended value", cmd_name);
719  }
720 
721  if (args[0] == "true") {
722  cmd->set_suspended(true);
723  } else if (args[0] == "false") {
724  cmd->set_suspended(false);
725  } else {
726  return cmd_brorg_help("invalid suspended value", cmd_name);
727  }
728 
729  args.erase(args.begin());
730  } else if (args[0] == "-type") {
731  //type
732  args.erase(args.begin());
733  if (args.empty()) {
734  return cmd_brorg_help("unspecified type", cmd_name);
735  }
736  string type = args[0];
737  args.erase(args.begin());
738  if (SheppStrUtil::quote_gathering(args, type) != 0) {
739  return cmd_brorg_help("error setting type", cmd_name);
740  }
741  cmd->set_type(type);
742 
743  } else if (args[0] == "-epp-status") {
744  //EPP status
745  args.erase(args.begin());
746  if (args.empty()) {
747  return cmd_brorg_help("unspecified EPP status", cmd_name);
748  }
749  string epp_status = args[0];
750  args.erase(args.begin());
751  if (SheppStrUtil::quote_gathering(args, epp_status) != 0) {
752  return cmd_brorg_help("error setting EPP status", cmd_name);
753  }
754  cmd->set_epp_status(epp_status);
755 
756  } else if (args[0] == "-epp-password") {
757  //EPP password
758  args.erase(args.begin());
759  if (args.empty()) {
760  return cmd_brorg_help("unspecified EPP password", cmd_name);
761  }
762  string epp_password = args[0];
763  args.erase(args.begin());
764  if (SheppStrUtil::quote_gathering(args, epp_password) != 0) {
765  return cmd_brorg_help("error setting EPP password", cmd_name);
766  }
767  cmd->set_epp_password(epp_password);
768 
769  } else if (args[0] == "-epp-ip-add") {
770  //EPP IP or range to add
771  args.erase(args.begin());
772  if (args.empty()) {
773  return cmd_brorg_help("unspecified EPP IP add", cmd_name);
774  }
775  string epp_ip = args[0];
776  args.erase(args.begin());
777  if (SheppStrUtil::quote_gathering(args, epp_ip) != 0) {
778  return cmd_brorg_help("error setting EPP IP add", cmd_name);
779  }
780  cmd->insert_epp_ip_add(epp_ip);
781 
782  } else if (args[0] == "-epp-ip-rem") {
783  //EPP IP or range to remove
784  args.erase(args.begin());
785  if (args.empty()) {
786  return cmd_brorg_help("unspecified EPP IP rem", cmd_name);
787  }
788  string epp_ip = args[0];
789  args.erase(args.begin());
790  if (SheppStrUtil::quote_gathering(args, epp_ip) != 0) {
791  return cmd_brorg_help("error setting EPP IP rem", cmd_name);
792  }
793  cmd->insert_epp_ip_rem(epp_ip);
794 
795  } else if (args[0] == "-renewal-type-add") {
796  //Renewal type
797  args.erase(args.begin());
798  if (args.empty()) {
799  return cmd_brorg_help("unspecified renewal type add", cmd_name);
800  }
801  string renewal_type = args[0];
802  args.erase(args.begin());
803  if (SheppStrUtil::quote_gathering(args, renewal_type) != 0) {
804  return cmd_brorg_help("error setting renewal type add", cmd_name);
805  }
806  cmd->insert_renewal_type_add(renewal_type);
807 
808  } else if (args[0] == "-renewal-type-rem") {
809  //Renewal type
810  args.erase(args.begin());
811  if (args.empty()) {
812  return cmd_brorg_help("unspecified renewal type rem", cmd_name);
813  }
814  string renewal_type = args[0];
815  args.erase(args.begin());
816  if (SheppStrUtil::quote_gathering(args, renewal_type) != 0) {
817  return cmd_brorg_help("error setting renewal type rem", cmd_name);
818  }
819  cmd->insert_renewal_type_rem(renewal_type);
820 
821  } else if (args[0] == "-resources-class") {
822  //Resources class
823  args.erase(args.begin());
824  if (args.empty()) {
825  return cmd_brorg_help("unspecified resources class", cmd_name);
826  }
827  string resources_class = args[0];
828  args.erase(args.begin());
829  if (SheppStrUtil::quote_gathering(args, resources_class) != 0) {
830  return cmd_brorg_help("error setting resources class", cmd_name);
831  }
832  cmd->set_resources_class(resources_class);
833 
834  } else if (args[0] == "-password") {
835  //Password
836  args.erase(args.begin());
837  if (args.empty()) {
838  return cmd_brorg_help("unspecified password", cmd_name);
839  }
840  string password = args[0];
841  args.erase(args.begin());
842  if (SheppStrUtil::quote_gathering(args, password) != 0) {
843  return cmd_brorg_help("error setting password", cmd_name);
844  }
845  cmd->set_password(password);
846 
847  } else {
848  return cmd_brorg_help("invalid syntax near \"" + args[0] + "\"",
849  cmd_name);
850  }
851  }
852 
853  if (cmd->get_status_list_add().empty() &&
854  cmd->get_status_list_rem().empty() &&
855  common_data.get_postal_info().empty() &&
856  common_data.get_voice().number == "" &&
857  common_data.get_fax().number == "" &&
858  common_data.get_email() == "" &&
859  cmd->get_authInfo().get_pw() == "" &&
860  !common_data.get_disclose().is_set() &&
861  cmd->get_organization() == "" &&
862  cmd->get_type().empty() &&
863  cmd->get_epp_status().empty() &&
864  cmd->get_epp_password().empty() &&
865  cmd->get_epp_ips_add().empty() &&
866  cmd->get_epp_ips_rem().empty() &&
867  cmd->get_renewal_types_add().empty() &&
868  cmd->get_renewal_types_rem().empty() &&
869  cmd->get_resources_class().empty()) {
870  return cmd_brorg_help("not enough information for update", cmd_name);
871  }
872 
873  cmd->set_common_data(common_data);
874 
875  if (_debug) {
876  printf(" brorg: [%s]\n", cmd->get_common_data().get_id().c_str());
877 
878  set<string> status = cmd->get_status_list_add();
879  set<string>::const_iterator st_it;
880  if (!status.empty()) {
881  printf(" status to add: [ ");
882  for (st_it = status.begin(); st_it != status.end(); st_it++) {
883  printf("%s ", (*st_it).c_str());
884  }
885  printf("]\n");
886  }
887 
888  status = cmd->get_status_list_rem();
889  if (!status.empty()) {
890  printf(" status to rem: [ ");
891  for (st_it = status.begin(); st_it != status.end(); st_it++) {
892  printf("%s ", (*st_it).c_str());
893  }
894  printf("]\n");
895  }
896 
897  vector<PostalInfo> postal_list;
898  postal_list = cmd->get_common_data().get_postal_info();
899  for (int i = 0; i < (int) postal_list.size(); i++) {
900  SheppPrint::postal_info(postal_list[i]);
901  }
902 
903  if (cmd->get_common_data().get_voice().number != "") {
904  printf(" voice:");
906  }
907 
908  if (cmd->get_common_data().get_fax().number != "") {
909  printf(" fax :");
911  }
912 
913  if (cmd->get_common_data().get_email() != "") {
914  printf(" email: [%s]\n", cmd->get_common_data().get_email().c_str());
915  }
916 
917  if (cmd->get_authInfo().get_pw() != "") {
919  }
920 
921  if (cmd->get_common_data().get_disclose().is_set()) {
923  }
924 
925  //brorg
926  if (cmd->get_organization() != "") {
927  printf(" orgid: [%s]\n", cmd->get_organization().c_str());
928 
929  map<string, string, less<string> > contacts =
930  cmd->get_contact_list_add();
931  map<string, string, less<string> >::const_iterator c_it;
932  for (c_it = contacts.begin(); c_it != contacts.end(); c_it++) {
933  printf(" contact to add [%s] = [%s]\n", (*c_it).first.c_str(),
934  (*c_it).second.c_str());
935  }
936 
937  contacts = cmd->get_contact_list_rem();
938  for (c_it = contacts.begin(); c_it != contacts.end(); c_it++) {
939  printf(" contact to rem [%s] = [%s]\n", (*c_it).first.c_str(),
940  (*c_it).second.c_str());
941  }
942  }
943 
944  // lacnicorg
945  if (!cmd->get_type().empty()) {
946  printf(" type: [%s]\n", cmd->get_type().c_str());
947  }
948 
949  if (!cmd->get_epp_status().empty()) {
950  printf(" epp status: [%s]\n", cmd->get_epp_status().c_str());
951  }
952 
953  if (!cmd->get_epp_password().empty()) {
954  printf(" epp password: [%s]\n", cmd->get_epp_password().c_str());
955  }
956 
957  if (!cmd->get_epp_ips_add().empty()) {
958  vector<string> eppIPsAdd = cmd->get_epp_ips_add();
959  for (unsigned int i = 0; i < eppIPsAdd.size(); i++) {
960  printf(" epp ip add: [%s]\n", eppIPsAdd[i].c_str());
961  }
962  }
963 
964  if (!cmd->get_epp_ips_rem().empty()) {
965  vector<string> eppIPsRem = cmd->get_epp_ips_rem();
966  for (unsigned int i = 0; i < eppIPsRem.size(); i++) {
967  printf(" epp ip rem: [%s]\n", eppIPsRem[i].c_str());
968  }
969  }
970 
971  if (!cmd->get_renewal_types_add().empty()) {
972  vector<string> renewalTypesAdd = cmd->get_renewal_types_add();
973  for (unsigned int i = 0; i < renewalTypesAdd.size(); i++) {
974  printf(" renewal types add: [%s]\n", renewalTypesAdd[i].c_str());
975  }
976  }
977 
978  if (!cmd->get_renewal_types_rem().empty()) {
979  vector<string> renewalTypesRem = cmd->get_renewal_types_rem();
980  for (unsigned int i = 0; i < renewalTypesRem.size(); i++) {
981  printf(" renewal types rem: [%s]\n", renewalTypesRem[i].c_str());
982  }
983  }
984 
985  if (!cmd->get_resources_class().empty()) {
986  printf(" resources class: %s\n", cmd->get_resources_class().c_str());
987  }
988  } // _debug
989 
990  if (process_action(act) != 0) {
991  return -1;
992  }
993 
994  return 0;
995 }
996 
998 
1002 int cmd_brorg(vector<string> &args)
1003 {
1004  // brorg command processing
1005  if (!args.empty() && !(args[0] == "help")) {
1006  if (args[0] == "check") {
1007  args.erase(args.begin());
1008  return cmd_brorg_check(args);
1009  } else if (args[0] == "info") {
1010  args.erase(args.begin());
1011  return cmd_brorg_info(args);
1012  } else if (args[0] == "transfer") {
1013  args.erase(args.begin());
1014  return cmd_brorg_transfer(args);
1015  } else if (args[0] == "create") {
1016  args.erase(args.begin());
1017  return cmd_brorg_create(args);
1018  } else if (args[0] == "delete") {
1019  args.erase(args.begin());
1020  return cmd_brorg_delete(args);
1021  } else if (args[0] == "renew") {
1022  args.erase(args.begin());
1023  return cmd_brorg_renew(args);
1024  } else if (args[0] == "update") {
1025  args.erase(args.begin());
1026  return cmd_brorg_update(args);
1027  } else {
1028  return cmd_brorg_help("invalid command: brorg " + args[0]);
1029  }
1030  }
1031 
1032  return cmd_brorg_help("");
1033 }
1034 
1035 #endif //__BRORG_FUNCTIONS_H__
map< string, string, less< string > > get_contact_list_add() const
Returns the Contact List of additions.
Definition: BrOrgUpdateCmd.H:114
string get_resources_class() const
Returns the organization resources class.
Definition: BrOrgCreateCmd.H:209
string get_epp_status() const
Returns the EPP Status.
Definition: BrOrgUpdateCmd.H:192
void set_id(const string &id)
Sets the contact's id.
Definition: ContactInfoCmd.H:37
string get_organization() const
Returns the Organization.
Definition: BrOrgCreateCmd.H:49
string get_type() const
Returns the organization type.
Definition: BrOrgCreateCmd.H:126
int cmd_brorg_delete(vector< string > &args)
brorg delete command function
Definition: BrOrgFunctions.H:507
EPP BrOrgDeleteCmd Class.
Definition: BrOrgDeleteCmd.H:21
string get_id() const
Returns the contact's id.
Definition: ContactInfoCmd.H:43
int cmd_brorg_info(vector< string > &args)
brorg info command function
Definition: BrOrgFunctions.H:158
void set_id(const string &id)
id to be deleted
Definition: ContactDeleteCmd.H:37
void insert_contact(const string &type, const string &id)
Inserts a Contact into the list.
Definition: BrOrgCreateCmd.H:96
EPP BrOrgDelete Class.
static int split(string input, string &first, string &second, string splitter, bool relaxed=false)
Definition: SheppStrUtil.H:120
AuthInfo get_authInfo() const
Returns authorization information.
Definition: ContactUpdateCmd.H:96
void set_id(const string &id)
Sets the object's id.
int cmd_brorg_check(vector< string > &args)
brorg check command function
Definition: BrOrgFunctions.H:116
vector< string > get_epp_ips_add() const
Definition: BrOrgUpdateCmd.H:230
BrOrgUpdateCmd * get_command()
Returns raw pointer to the command.
Definition: BrOrgUpdate.H:45
int cmd_brorg(vector< string > &args)
main brorg command
Definition: BrOrgFunctions.H:1002
string get_email() const
Returns the object's email.
int cmd_brorg_renew(vector< string > &args)
brorg renew command function
Definition: BrOrgFunctions.H:533
map< string, string, less< string > > get_contact_list_rem() const
Returns the Contact List.
Definition: BrOrgUpdateCmd.H:133
EPP BrOrgUpdate Class.
int cmd_brorg_update(vector< string > &args)
brorg update command function
Definition: BrOrgFunctions.H:544
void set_organization(const string &organization)
Sets Organization attribute.
Definition: BrOrgCreateCmd.H:40
Disclose get_disclose() const
Returns the object's disclosure policy.
string get_organization() const
Returns the Organization.
Definition: BrOrgUpdateCmd.H:49
void set_disclose(const Disclose &disclose)
Sets the object's disclosure policy.
map< string, string, less< string > > get_contact_list() const
Returns the Contact List.
Definition: BrOrgCreateCmd.H:105
EPP BrOrgUpdate Class.
Definition: BrOrgUpdate.H:23
void set_email(const string &email)
Sets the object's email.
static void authInfo(AuthInfo auth)
prints an AuthInfo object
Definition: SheppPrint.H:21
static int phone(CommonData::Phone &phone, vector< string > &words)
fills a Phone based on input command line
Definition: SheppObjSet.H:546
void insert_status_list_add(const string &status_add)
Inserts a status to the object.
Definition: ContactUpdateCmd.H:42
vector< string > get_epp_ips_rem() const
Definition: BrOrgUpdateCmd.H:250
void insert_organization(const string &id, const string &organization)
Inserts an Organization attribute.
Definition: BrOrgCheckCmd.H:40
AuthInfo get_authInfo()
Returns authorization information.
Definition: ContactCreateCmd.H:66
EPP BrOrgInfoCmd Class.
Definition: BrOrgInfoCmd.H:21
void set_organization(const string &organization)
Sets the Organization.
Definition: BrOrgDeleteCmd.H:36
set< string > get_status_list_add() const
Returns the list of status to be added to the object.
Definition: ContactUpdateCmd.H:60
void set_suspended(const bool suspended)
Sets suspended by payment flag.
Definition: BrOrgUpdateCmd.H:143
EPP BrOrgInfo Class.
void set_responsible(const string &responsible)
Sets Responsible for the organization.
Definition: BrOrgUpdateCmd.H:58
int cmd_brorg_help(string error_msg, string specific="")
print brorg command usage info
Definition: BrOrgFunctions.H:22
PostalInfo class.
Definition: CommonData.H:281
EPP BrOrgCreate Class.
void set_fax(const Phone &fax)
Sets the object's fax number.
void insert_postal_info(const PostalInfo &postal_info)
Inserts postal information into the object.
void insert_epp_ip(const string &ip)
Definition: BrOrgCreateCmd.H:154
set< string > get_status_list_rem() const
Returns the list of status to be removed from the object.
Definition: ContactUpdateCmd.H:66
set< string > get_id_list() const
Returns contact id list.
Definition: ContactCheckCmd.H:44
void set_authInfo(const AuthInfo &authInfo)
Sets authorization information.
Definition: ContactInfoCmd.H:56
EPP BrOrgCheck Class.
Definition: BrOrgCheck.H:17
string get_organization() const
Returns the Organization.
Definition: BrOrgInfoCmd.H:45
EPP BrOrgUpdateCmd Class.
Definition: BrOrgUpdateCmd.H:25
Phone get_fax() const
Returns the object's fax number.
void insert_renewal_type(const string &type)
Inserts a renewal type.
Definition: BrOrgCreateCmd.H:173
void set_authInfo(const AuthInfo &authInfo)
Sets authorization information.
Definition: ContactUpdateCmd.H:87
CommonData get_common_data() const
Returns the common data object.
Definition: ContactUpdateCmd.H:81
void set_authInfo(const AuthInfo &authInfo)
Sets authorization information.
Definition: ContactCreateCmd.H:57
void insert_renewal_type_add(const string &type)
Inserts a renewal type to be added.
Definition: BrOrgUpdateCmd.H:259
void set_epp_password(const string &password)
Sets the EPP password.
Definition: BrOrgUpdateCmd.H:201
vector< string > get_renewal_types_add() const
Returns the renewal types to be added.
Definition: BrOrgUpdateCmd.H:268
EPP BrOrgInfo Class.
Definition: BrOrgInfo.H:23
void set_common_data(const CommonData &common)
Sets the common data object.
Definition: ContactUpdateCmd.H:72
void insert_epp_ip_rem(const string &ip)
Definition: BrOrgUpdateCmd.H:240
string get_resources_class() const
Returns the organization resources class.
Definition: BrOrgUpdateCmd.H:304
void set_voice(const Phone &voice)
Sets the object's voice telephone number.
void insert_contact_rem(const string &type, const string &id)
Inserts a Contact into the list of deletions.
Definition: BrOrgUpdateCmd.H:124
void set_epp_status(const string &epp_status)
Sets the EPP Status.
Definition: BrOrgUpdateCmd.H:183
string get_type() const
Returns the organization type.
Definition: BrOrgUpdateCmd.H:171
void insert_contact_add(const string &type, const string &id)
Inserts a Contact into the list of additions.
Definition: BrOrgUpdateCmd.H:105
static void postal_info(PostalInfo postal)
prints a PostalInfo object
Definition: SheppPrint.H:53
bool get_roid_f() const
Returns the roid change flag.
Definition: CommonData.H:121
int process_action(Action &act)
Send and EPP Action.
Definition: SheppCommandFunctions.H:871
EPP BrOrgDelete Class.
Definition: BrOrgDelete.H:23
Definition: CommonData.H:491
void set_organization(const string &organization)
Sets the Organization.
Definition: BrOrgInfoCmd.H:36
vector< PostalInfo > get_postal_info() const
Returns the object's postal information.
void set_exDate(const string &exDate)
Sets expiration date.
Definition: BrOrgUpdateCmd.H:92
vector< string > get_epp_ips() const
Definition: BrOrgCreateCmd.H:164
static void disclose(CommonData::Disclose disclose)
prints a Disclose object
Definition: SheppPrint.H:106
CommonData get_common_data() const
Returns a common data object raw pointer.
Definition: ContactCreateCmd.H:51
static int postalInfo(PostalInfo &postal, vector< string > &words, string &error_msg, bool relaxed)
fills a PostalInfo based on input command line
Definition: SheppObjSet.H:357
vector< string > get_renewal_types() const
Returns list of renewal types of an organization.
Definition: BrOrgCreateCmd.H:191
EPP CommonData Class.
Definition: CommonData.H:487
Phone get_voice() const
Returns the object's voice telephone number.
string get_pw() const
Returns the password.
Definition: CommonData.H:140
void set_responsible(const string &responsible)
Sets the responsible for the organization.
Definition: BrOrgCreateCmd.H:58
vector< string > get_renewal_types_rem() const
Returns the renewal types to be removed.
Definition: BrOrgUpdateCmd.H:286
AuthInfo get_authInfo() const
Returns authorization information.
Definition: ContactInfoCmd.H:65
void set_type(const string &type)
Sets the organization type.
Definition: BrOrgUpdateCmd.H:162
EPP command-line shell client command functions include file.
static int disclose(CommonData::Disclose &disclose, string word)
fills a Disclose based on input command line
Definition: SheppObjSet.H:563
Definition: CommonData.H:524
BrOrgInfoCmd * get_command()
Returns raw pointer to the command.
Definition: BrOrgInfo.H:45
void insert_status_list_rem(const string &status_rem)
Removes a status from the object.
Definition: ContactUpdateCmd.H:51
void set_password(const string &password)
Sets the legacy organization password.
Definition: BrOrgUpdateCmd.H:313
void insert_id(const string &id)
Inserts an id into id list.
Definition: ContactCheckCmd.H:38
static int quote_gathering(vector< string > &words, string &gather)
Gathers command-line arguments bounded by quotes in a string.
Definition: SheppStrUtil.H:152
BrOrgCheckCmd * get_command()
Returns raw pointer to the command.
Definition: BrOrgCheck.H:48
int cmd_contact_help(string error_msg, string specific="")
print contact command usage info
Definition: ContactFunctions.H:23
void set_common_data(const CommonData &common)
Sets the common data object.
Definition: ContactCreateCmd.H:42
EPP BrOrgCreateCmd Class.
Definition: BrOrgCreateCmd.H:25
map< string, string, less< string > > get_organization_list() const
Returns the Organization List.
Definition: BrOrgCheckCmd.H:49
EPP BrOrgCheckCmd Class.
Definition: BrOrgCheckCmd.H:24
void set_epp_password(const string &password)
Sets the EPP password.
Definition: BrOrgCreateCmd.H:135
void set_organization(const string &organization)
Sets Organization attribute.
Definition: BrOrgUpdateCmd.H:40
EPP BrOrgCheck Class.
void insert_renewal_type_rem(const string &type)
Inserts a renewal type to be removed.
Definition: BrOrgUpdateCmd.H:277
string get_epp_password() const
Returns the EPP password.
Definition: BrOrgCreateCmd.H:144
void set_resources_class(const string &resources_class)
Sets the organization resources class.
Definition: BrOrgCreateCmd.H:200
int cmd_brorg_transfer(vector< string > &args)
brorg transfer command function
Definition: BrOrgFunctions.H:211
int cmd_brorg_create(vector< string > &args)
brorg create command function
Definition: BrOrgFunctions.H:222
void insert_epp_ip_add(const string &ip)
Definition: BrOrgUpdateCmd.H:220
void set_resources_class(const string &resources_class)
Sets the organization resources class.
Definition: BrOrgUpdateCmd.H:295
string get_id() const
Returns the object's id.
static int contacts(map< string, string, less< string > > &contacts, string args, string &error_msg)
fills a map of contacts based on input command line
Definition: SheppObjSet.H:604
string get_epp_password() const
Returns the EPP password.
Definition: BrOrgUpdateCmd.H:210
EPP BrOrgCreate Class.
Definition: BrOrgCreate.H:23
static int authInfo(AuthInfo &auth, vector< string > &words)
fills an AuthInfo based on input command line
Definition: SheppObjSet.H:54
BrOrgCreateCmd * get_command()
Returns raw pointer to the command.
Definition: BrOrgCreate.H:45
static string doc2id(const string &doc)
Removes chars [./-] from document strings.
Definition: SheppStrUtil.H:196
static void phone(CommonData::Phone phone)
prints a Phone object
Definition: SheppPrint.H:96
BrOrgDeleteCmd * get_command()
Returns raw pointer to the command.
Definition: BrOrgDelete.H:45
AuthInfo Class.
Definition: CommonData.H:83
void set_type(const string &type)
Sets the organization type.
Definition: BrOrgCreateCmd.H:117