/condor-7.9.0/src/condor_contrib/aviary/codegen/common/src/AviaryCommon_ResourceLocation.cpp

# · C++ · 1258 lines · 731 code · 397 blank · 130 comment · 164 complexity · 1539dc6ac4d3aab1b8263eaeaa99e8af MD5 · raw file

  1. /**
  2. * ResourceLocation.cpp
  3. *
  4. * This file was auto-generated from WSDL
  5. * by the Apache Axis2/C version: SNAPSHOT Built on : Mar 10, 2008 (08:35:52 GMT+00:00)
  6. */
  7. #include "AviaryCommon_ResourceLocation.h"
  8. #include <Environment.h>
  9. #include <WSFError.h>
  10. using namespace wso2wsf;
  11. using namespace std;
  12. using namespace AviaryCommon;
  13. /*
  14. * This type was generated from the piece of schema that had
  15. * name = ResourceLocation
  16. * Namespace URI = http://common.aviary.grid.redhat.com
  17. * Namespace Prefix = ns1
  18. */
  19. AviaryCommon::ResourceLocation::ResourceLocation()
  20. {
  21. property_Id = NULL;
  22. isValidId = false;
  23. property_Location = NULL;
  24. isValidLocation = false;
  25. property_Status = NULL;
  26. isValidStatus = false;
  27. }
  28. AviaryCommon::ResourceLocation::ResourceLocation(AviaryCommon::ResourceID* arg_Id,std::vector<axutil_uri_t*>* arg_Location,AviaryCommon::Status* arg_Status)
  29. {
  30. property_Id = NULL;
  31. isValidId = true;
  32. property_Location = NULL;
  33. isValidLocation = true;
  34. property_Status = NULL;
  35. isValidStatus = true;
  36. property_Id = arg_Id;
  37. property_Location = arg_Location;
  38. property_Status = arg_Status;
  39. }
  40. AviaryCommon::ResourceLocation::~ResourceLocation()
  41. {
  42. if (property_Id) delete property_Id;
  43. if (property_Location) delete property_Location;
  44. if (property_Status) delete property_Status;
  45. }
  46. bool WSF_CALL
  47. AviaryCommon::ResourceLocation::deserialize(axiom_node_t** dp_parent,bool *dp_is_early_node_valid, bool dont_care_minoccurs)
  48. {
  49. axiom_node_t *parent = *dp_parent;
  50. bool status = AXIS2_SUCCESS;
  51. const axis2_char_t* text_value = NULL;
  52. axutil_qname_t *mqname = NULL;
  53. int i = 0;
  54. int sequence_broken = 0;
  55. axiom_node_t *tmp_node = NULL;
  56. axutil_qname_t *element_qname = NULL;
  57. axiom_node_t *first_node = NULL;
  58. bool is_early_node_valid = true;
  59. axiom_node_t *current_node = NULL;
  60. axiom_element_t *current_element = NULL;
  61. while(parent && axiom_node_get_node_type(parent, Environment::getEnv()) != AXIOM_ELEMENT)
  62. {
  63. parent = axiom_node_get_next_sibling(parent, Environment::getEnv());
  64. }
  65. if (NULL == parent)
  66. {
  67. return AXIS2_FAILURE;
  68. }
  69. first_node = axiom_node_get_first_child(parent, Environment::getEnv());
  70. /*
  71. * building id element
  72. */
  73. current_node = first_node;
  74. is_early_node_valid = false;
  75. while(current_node && axiom_node_get_node_type(current_node, Environment::getEnv()) != AXIOM_ELEMENT)
  76. {
  77. current_node = axiom_node_get_next_sibling(current_node, Environment::getEnv());
  78. }
  79. if(current_node != NULL)
  80. {
  81. current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, Environment::getEnv());
  82. mqname = axiom_element_get_qname(current_element, Environment::getEnv(), current_node);
  83. }
  84. element_qname = axutil_qname_create(Environment::getEnv(), "id", NULL, NULL);
  85. if (isParticle() ||
  86. (current_node && current_element && (axutil_qname_equals(element_qname, Environment::getEnv(), mqname) || !axutil_strcmp("id", axiom_element_get_localname(current_element, Environment::getEnv())))))
  87. {
  88. if( current_node && current_element && (axutil_qname_equals(element_qname, Environment::getEnv(), mqname) || !axutil_strcmp("id", axiom_element_get_localname(current_element, Environment::getEnv()))))
  89. {
  90. is_early_node_valid = true;
  91. }
  92. AviaryCommon::ResourceID* element = new AviaryCommon::ResourceID();
  93. status = element->deserialize(&current_node, &is_early_node_valid, false);
  94. if(AXIS2_FAILURE == status)
  95. {
  96. WSF_LOG_ERROR_MSG(Environment::getEnv()->log, WSF_LOG_SI, "failed in building adb object for element id");
  97. }
  98. else
  99. {
  100. status = setId(element);
  101. }
  102. if(AXIS2_FAILURE == status)
  103. {
  104. WSF_LOG_ERROR_MSG( Environment::getEnv()->log,WSF_LOG_SI,"failed in setting the value for id ");
  105. if(element_qname)
  106. {
  107. axutil_qname_free(element_qname, Environment::getEnv());
  108. }
  109. return AXIS2_FAILURE;
  110. }
  111. }
  112. else if(!dont_care_minoccurs)
  113. {
  114. if(element_qname)
  115. {
  116. axutil_qname_free(element_qname, Environment::getEnv());
  117. }
  118. /* this is not a nillable element*/
  119. WSF_LOG_ERROR_MSG(Environment::getEnv()->log,WSF_LOG_SI, "non nillable or minOuccrs != 0 element id missing");
  120. return AXIS2_FAILURE;
  121. }
  122. if(element_qname)
  123. {
  124. axutil_qname_free(element_qname, Environment::getEnv());
  125. element_qname = NULL;
  126. }
  127. {
  128. /*
  129. * building Location array
  130. */
  131. std::vector<axutil_uri_t*>* arr_list =new std::vector<axutil_uri_t*>();
  132. /*
  133. * building location element
  134. */
  135. element_qname = axutil_qname_create(Environment::getEnv(), "location", NULL, NULL);
  136. for (i = 0, sequence_broken = 0, current_node = (is_early_node_valid?axiom_node_get_next_sibling(current_node, Environment::getEnv()):current_node); !sequence_broken && current_node != NULL;)
  137. {
  138. if(axiom_node_get_node_type(current_node, Environment::getEnv()) != AXIOM_ELEMENT)
  139. {
  140. current_node =axiom_node_get_next_sibling(current_node, Environment::getEnv());
  141. is_early_node_valid = false;
  142. continue;
  143. }
  144. current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, Environment::getEnv());
  145. mqname = axiom_element_get_qname(current_element, Environment::getEnv(), current_node);
  146. if (axutil_qname_equals(element_qname, Environment::getEnv(), mqname) || !axutil_strcmp("location", axiom_element_get_localname(current_element, Environment::getEnv())))
  147. {
  148. is_early_node_valid = true;
  149. text_value = axiom_element_get_text(current_element, Environment::getEnv(), current_node);
  150. if(text_value != NULL)
  151. {
  152. arr_list->push_back(axutil_uri_parse_string(Environment::getEnv(), text_value));
  153. }
  154. else
  155. {
  156. WSF_LOG_ERROR_MSG(Environment::getEnv()->log,WSF_LOG_SI, "NULL value is set to a non nillable element location");
  157. status = AXIS2_FAILURE;
  158. }
  159. if(AXIS2_FAILURE == status)
  160. {
  161. WSF_LOG_ERROR_MSG(Environment::getEnv()->log, WSF_LOG_SI, "failed in setting the value for location ");
  162. if(element_qname)
  163. {
  164. axutil_qname_free(element_qname, Environment::getEnv());
  165. }
  166. if(arr_list)
  167. {
  168. delete arr_list;
  169. }
  170. return false;
  171. }
  172. i++;
  173. current_node = axiom_node_get_next_sibling(current_node, Environment::getEnv());
  174. }
  175. else
  176. {
  177. is_early_node_valid = false;
  178. sequence_broken = 1;
  179. }
  180. }
  181. if (i < 0)
  182. {
  183. /* found element out of order */
  184. WSF_LOG_ERROR_MSG( Environment::getEnv()->log,WSF_LOG_SI,"location (@minOccurs = '0') only have %d elements", i);
  185. if(element_qname)
  186. {
  187. axutil_qname_free(element_qname, Environment::getEnv());
  188. }
  189. if(arr_list)
  190. {
  191. delete arr_list;
  192. }
  193. return false;
  194. }
  195. if(0 == arr_list->size())
  196. {
  197. delete arr_list;
  198. }
  199. else
  200. {
  201. status = setLocation(arr_list);
  202. }
  203. }
  204. if(element_qname)
  205. {
  206. axutil_qname_free(element_qname, Environment::getEnv());
  207. element_qname = NULL;
  208. }
  209. /*
  210. * building status element
  211. */
  212. /*
  213. * because elements are ordered this works fine
  214. */
  215. if(current_node != NULL && is_early_node_valid)
  216. {
  217. current_node = axiom_node_get_next_sibling(current_node, Environment::getEnv());
  218. while(current_node && axiom_node_get_node_type(current_node, Environment::getEnv()) != AXIOM_ELEMENT)
  219. {
  220. current_node = axiom_node_get_next_sibling(current_node, Environment::getEnv());
  221. }
  222. if(current_node != NULL)
  223. {
  224. current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, Environment::getEnv());
  225. mqname = axiom_element_get_qname(current_element, Environment::getEnv(), current_node);
  226. }
  227. }
  228. is_early_node_valid = false;
  229. element_qname = axutil_qname_create(Environment::getEnv(), "status", NULL, NULL);
  230. if (isParticle() ||
  231. (current_node && current_element && (axutil_qname_equals(element_qname, Environment::getEnv(), mqname) || !axutil_strcmp("status", axiom_element_get_localname(current_element, Environment::getEnv())))))
  232. {
  233. if( current_node && current_element && (axutil_qname_equals(element_qname, Environment::getEnv(), mqname) || !axutil_strcmp("status", axiom_element_get_localname(current_element, Environment::getEnv()))))
  234. {
  235. is_early_node_valid = true;
  236. }
  237. AviaryCommon::Status* element = new AviaryCommon::Status();
  238. status = element->deserialize(&current_node, &is_early_node_valid, false);
  239. if(AXIS2_FAILURE == status)
  240. {
  241. WSF_LOG_ERROR_MSG(Environment::getEnv()->log, WSF_LOG_SI, "failed in building adb object for element status");
  242. }
  243. else
  244. {
  245. status = setStatus(element);
  246. }
  247. if(AXIS2_FAILURE == status)
  248. {
  249. WSF_LOG_ERROR_MSG( Environment::getEnv()->log,WSF_LOG_SI,"failed in setting the value for status ");
  250. if(element_qname)
  251. {
  252. axutil_qname_free(element_qname, Environment::getEnv());
  253. }
  254. return AXIS2_FAILURE;
  255. }
  256. }
  257. else if(!dont_care_minoccurs)
  258. {
  259. if(element_qname)
  260. {
  261. axutil_qname_free(element_qname, Environment::getEnv());
  262. }
  263. /* this is not a nillable element*/
  264. WSF_LOG_ERROR_MSG(Environment::getEnv()->log,WSF_LOG_SI, "non nillable or minOuccrs != 0 element status missing");
  265. return AXIS2_FAILURE;
  266. }
  267. if(element_qname)
  268. {
  269. axutil_qname_free(element_qname, Environment::getEnv());
  270. element_qname = NULL;
  271. }
  272. return status;
  273. }
  274. bool WSF_CALL
  275. AviaryCommon::ResourceLocation::isParticle()
  276. {
  277. return false;
  278. }
  279. void WSF_CALL
  280. AviaryCommon::ResourceLocation::declareParentNamespaces(
  281. axiom_element_t *parent_element,
  282. axutil_hash_t *namespaces, int *next_ns_index)
  283. {
  284. /* Here this is an empty function, Nothing to declare */
  285. }
  286. axiom_node_t* WSF_CALL
  287. AviaryCommon::ResourceLocation::serialize(axiom_node_t *parent,
  288. axiom_element_t *parent_element,
  289. int parent_tag_closed,
  290. axutil_hash_t *namespaces,
  291. int *next_ns_index)
  292. {
  293. axis2_char_t *string_to_stream;
  294. axiom_node_t *current_node = NULL;
  295. int tag_closed = 0;
  296. axiom_namespace_t *ns1 = NULL;
  297. axis2_char_t *qname_uri = NULL;
  298. axis2_char_t *qname_prefix = NULL;
  299. axis2_char_t *p_prefix = NULL;
  300. int i = 0;
  301. int count = 0;
  302. void *element = NULL;
  303. axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT];
  304. axis2_char_t *text_value_2;
  305. axis2_char_t *text_value_2_temp;
  306. axis2_char_t text_value_3[ADB_DEFAULT_DIGIT_LIMIT];
  307. axis2_char_t *start_input_str = NULL;
  308. axis2_char_t *end_input_str = NULL;
  309. unsigned int start_input_str_len = 0;
  310. unsigned int end_input_str_len = 0;
  311. axiom_data_source_t *data_source = NULL;
  312. axutil_stream_t *stream = NULL;
  313. current_node = parent;
  314. data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, Environment::getEnv());
  315. if (!data_source)
  316. return NULL;
  317. stream = axiom_data_source_get_stream(data_source, Environment::getEnv()); /* assume parent is of type data source */
  318. if (!stream)
  319. return NULL;
  320. if(!parent_tag_closed)
  321. {
  322. string_to_stream = ">";
  323. axutil_stream_write(stream, Environment::getEnv(), string_to_stream, axutil_strlen(string_to_stream));
  324. tag_closed = 1;
  325. }
  326. p_prefix = NULL;
  327. if (!isValidId)
  328. {
  329. WSF_LOG_ERROR_MSG( Environment::getEnv()->log,WSF_LOG_SI,"Nil value found in non-nillable property id");
  330. return NULL;
  331. }
  332. else
  333. {
  334. start_input_str = (axis2_char_t*)AXIS2_MALLOC(Environment::getEnv()->allocator, sizeof(axis2_char_t) *
  335. (4 + axutil_strlen(p_prefix) +
  336. axutil_strlen("id")));
  337. /* axutil_strlen("<:>") + 1 = 4 */
  338. end_input_str = (axis2_char_t*)AXIS2_MALLOC(Environment::getEnv()->allocator, sizeof(axis2_char_t) *
  339. (5 + axutil_strlen(p_prefix) + axutil_strlen("id")));
  340. /* axutil_strlen("</:>") + 1 = 5 */
  341. /*
  342. * parsing id element
  343. */
  344. sprintf(start_input_str, "<%s%sid",
  345. p_prefix?p_prefix:"",
  346. (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
  347. start_input_str_len = axutil_strlen(start_input_str);
  348. sprintf(end_input_str, "</%s%sid>",
  349. p_prefix?p_prefix:"",
  350. (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
  351. end_input_str_len = axutil_strlen(end_input_str);
  352. if(!property_Id->isParticle())
  353. {
  354. axutil_stream_write(stream, Environment::getEnv(), start_input_str, start_input_str_len);
  355. }
  356. property_Id->serialize(current_node, parent_element,
  357. property_Id->isParticle() || false, namespaces, next_ns_index);
  358. if(!property_Id->isParticle())
  359. {
  360. axutil_stream_write(stream, Environment::getEnv(), end_input_str, end_input_str_len);
  361. }
  362. AXIS2_FREE(Environment::getEnv()->allocator,start_input_str);
  363. AXIS2_FREE(Environment::getEnv()->allocator,end_input_str);
  364. }
  365. p_prefix = NULL;
  366. if (!isValidLocation)
  367. {
  368. /* no need to complain for minoccurs=0 element */
  369. }
  370. else
  371. {
  372. start_input_str = (axis2_char_t*)AXIS2_MALLOC(Environment::getEnv()->allocator, sizeof(axis2_char_t) *
  373. (4 + axutil_strlen(p_prefix) +
  374. axutil_strlen("location")));
  375. /* axutil_strlen("<:>") + 1 = 4 */
  376. end_input_str = (axis2_char_t*)AXIS2_MALLOC(Environment::getEnv()->allocator, sizeof(axis2_char_t) *
  377. (5 + axutil_strlen(p_prefix) + axutil_strlen("location")));
  378. /* axutil_strlen("</:>") + 1 = 5 */
  379. /*
  380. * Parsing Location array
  381. */
  382. if (property_Location != NULL)
  383. {
  384. sprintf(start_input_str, "<%s%slocation>",
  385. p_prefix?p_prefix:"",
  386. (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
  387. start_input_str_len = axutil_strlen(start_input_str);
  388. sprintf(end_input_str, "</%s%slocation>",
  389. p_prefix?p_prefix:"",
  390. (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
  391. end_input_str_len = axutil_strlen(end_input_str);
  392. count = property_Location->size();
  393. for(i = 0; i < count; i++)
  394. {
  395. axutil_uri_t* element = (*property_Location)[i];
  396. if(NULL == element)
  397. {
  398. continue;
  399. }
  400. /*
  401. * parsing location element
  402. */
  403. text_value_2 = axutil_uri_to_string(element, Environment::getEnv(), AXIS2_URI_UNP_OMITUSERINFO);
  404. axutil_stream_write(stream, Environment::getEnv(), start_input_str, start_input_str_len);
  405. axutil_stream_write(stream, Environment::getEnv(), text_value_2, axutil_strlen(text_value_2));
  406. axutil_stream_write(stream, Environment::getEnv(), end_input_str, end_input_str_len);
  407. }
  408. }
  409. AXIS2_FREE(Environment::getEnv()->allocator,start_input_str);
  410. AXIS2_FREE(Environment::getEnv()->allocator,end_input_str);
  411. }
  412. p_prefix = NULL;
  413. if (!isValidStatus)
  414. {
  415. WSF_LOG_ERROR_MSG( Environment::getEnv()->log,WSF_LOG_SI,"Nil value found in non-nillable property status");
  416. return NULL;
  417. }
  418. else
  419. {
  420. start_input_str = (axis2_char_t*)AXIS2_MALLOC(Environment::getEnv()->allocator, sizeof(axis2_char_t) *
  421. (4 + axutil_strlen(p_prefix) +
  422. axutil_strlen("status")));
  423. /* axutil_strlen("<:>") + 1 = 4 */
  424. end_input_str = (axis2_char_t*)AXIS2_MALLOC(Environment::getEnv()->allocator, sizeof(axis2_char_t) *
  425. (5 + axutil_strlen(p_prefix) + axutil_strlen("status")));
  426. /* axutil_strlen("</:>") + 1 = 5 */
  427. /*
  428. * parsing status element
  429. */
  430. sprintf(start_input_str, "<%s%sstatus",
  431. p_prefix?p_prefix:"",
  432. (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
  433. start_input_str_len = axutil_strlen(start_input_str);
  434. sprintf(end_input_str, "</%s%sstatus>",
  435. p_prefix?p_prefix:"",
  436. (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
  437. end_input_str_len = axutil_strlen(end_input_str);
  438. if(!property_Status->isParticle())
  439. {
  440. axutil_stream_write(stream, Environment::getEnv(), start_input_str, start_input_str_len);
  441. }
  442. property_Status->serialize(current_node, parent_element,
  443. property_Status->isParticle() || false, namespaces, next_ns_index);
  444. if(!property_Status->isParticle())
  445. {
  446. axutil_stream_write(stream, Environment::getEnv(), end_input_str, end_input_str_len);
  447. }
  448. AXIS2_FREE(Environment::getEnv()->allocator,start_input_str);
  449. AXIS2_FREE(Environment::getEnv()->allocator,end_input_str);
  450. }
  451. return parent;
  452. }
  453. /**
  454. * Getter for id by Property Number 1
  455. */
  456. AviaryCommon::ResourceID* WSF_CALL
  457. AviaryCommon::ResourceLocation::getProperty1()
  458. {
  459. return getId();
  460. }
  461. /**
  462. * getter for id.
  463. */
  464. AviaryCommon::ResourceID* WSF_CALL
  465. AviaryCommon::ResourceLocation::getId()
  466. {
  467. return property_Id;
  468. }
  469. /**
  470. * setter for id
  471. */
  472. bool WSF_CALL
  473. AviaryCommon::ResourceLocation::setId(
  474. AviaryCommon::ResourceID* arg_Id)
  475. {
  476. if(isValidId &&
  477. arg_Id == property_Id)
  478. {
  479. return true;
  480. }
  481. if(NULL == arg_Id)
  482. {
  483. WSF_LOG_ERROR_MSG( Environment::getEnv()->log,WSF_LOG_SI,"id is being set to NULL, but it is not a nullable element");
  484. return AXIS2_FAILURE;
  485. }
  486. resetId();
  487. if(NULL == arg_Id)
  488. {
  489. /* We are already done */
  490. return true;
  491. }
  492. property_Id = arg_Id;
  493. isValidId = true;
  494. return true;
  495. }
  496. /**
  497. * resetter for id
  498. */
  499. bool WSF_CALL
  500. AviaryCommon::ResourceLocation::resetId()
  501. {
  502. int i = 0;
  503. int count = 0;
  504. if(property_Id != NULL)
  505. {
  506. delete property_Id;
  507. }
  508. isValidId = false;
  509. return true;
  510. }
  511. /**
  512. * Check whether id is nill
  513. */
  514. bool WSF_CALL
  515. AviaryCommon::ResourceLocation::isIdNil()
  516. {
  517. return !isValidId;
  518. }
  519. /**
  520. * Set id to nill (currently the same as reset)
  521. */
  522. bool WSF_CALL
  523. AviaryCommon::ResourceLocation::setIdNil()
  524. {
  525. return resetId();
  526. }
  527. /**
  528. * Getter for location by Property Number 2
  529. */
  530. std::vector<axutil_uri_t*>* WSF_CALL
  531. AviaryCommon::ResourceLocation::getProperty2()
  532. {
  533. return getLocation();
  534. }
  535. /**
  536. * getter for location.
  537. */
  538. std::vector<axutil_uri_t*>* WSF_CALL
  539. AviaryCommon::ResourceLocation::getLocation()
  540. {
  541. return property_Location;
  542. }
  543. /**
  544. * setter for location
  545. */
  546. bool WSF_CALL
  547. AviaryCommon::ResourceLocation::setLocation(
  548. std::vector<axutil_uri_t*>* arg_Location)
  549. {
  550. int size = 0;
  551. int i = 0;
  552. bool non_nil_exists = false;
  553. if(isValidLocation &&
  554. arg_Location == property_Location)
  555. {
  556. return true;
  557. }
  558. size = arg_Location->size();
  559. if (size < 0)
  560. {
  561. WSF_LOG_ERROR_MSG( Environment::getEnv()->log,WSF_LOG_SI,"location has less than minOccurs(0)");
  562. return false;
  563. }
  564. for(i = 0; i < size; i ++ )
  565. {
  566. if(NULL != (*arg_Location)[i])
  567. {
  568. non_nil_exists = true;
  569. break;
  570. }
  571. }
  572. resetLocation();
  573. if(NULL == arg_Location)
  574. {
  575. /* We are already done */
  576. return true;
  577. }
  578. property_Location = arg_Location;
  579. if(non_nil_exists)
  580. {
  581. isValidLocation = true;
  582. }
  583. return true;
  584. }
  585. /**
  586. * Get ith element of location.
  587. */
  588. axutil_uri_t* WSF_CALL
  589. AviaryCommon::ResourceLocation::getLocationAt(int i)
  590. {
  591. axutil_uri_t* ret_val;
  592. if(property_Location == NULL)
  593. {
  594. return (axutil_uri_t*)0;
  595. }
  596. ret_val = (*property_Location)[i];
  597. return ret_val;
  598. }
  599. /**
  600. * Set the ith element of location.
  601. */
  602. bool WSF_CALL
  603. AviaryCommon::ResourceLocation::setLocationAt(int i,
  604. axutil_uri_t* arg_Location)
  605. {
  606. axutil_uri_t* element;
  607. int size = 0;
  608. int non_nil_count;
  609. bool non_nil_exists = false;
  610. if( isValidLocation &&
  611. property_Location &&
  612. arg_Location == (*property_Location)[i])
  613. {
  614. return AXIS2_SUCCESS;
  615. }
  616. non_nil_exists = true;
  617. if(property_Location == NULL)
  618. {
  619. property_Location = new std::vector<axutil_uri_t*>();
  620. }
  621. else{
  622. /* check whether there already exist an element */
  623. element = (*property_Location)[i];
  624. }
  625. if(NULL != element)
  626. {
  627. axutil_uri_free(element, Environment::getEnv());
  628. }
  629. if(!non_nil_exists)
  630. {
  631. isValidLocation = true;
  632. (*property_Location)[i]= NULL;
  633. return AXIS2_SUCCESS;
  634. }
  635. (*property_Location)[i] = arg_Location;
  636. isValidLocation = true;
  637. return AXIS2_SUCCESS;
  638. }
  639. /**
  640. * Add to location.
  641. */
  642. bool WSF_CALL
  643. AviaryCommon::ResourceLocation::addLocation(
  644. axutil_uri_t* arg_Location)
  645. {
  646. if( NULL == arg_Location
  647. )
  648. {
  649. return true;
  650. }
  651. if(property_Location == NULL)
  652. {
  653. property_Location = new std::vector<axutil_uri_t*>();
  654. }
  655. property_Location->push_back(arg_Location);
  656. isValidLocation = true;
  657. return true;
  658. }
  659. /**
  660. * Get the size of the location array.
  661. */
  662. int WSF_CALL
  663. AviaryCommon::ResourceLocation::sizeofLocation()
  664. {
  665. if(property_Location == NULL)
  666. {
  667. return 0;
  668. }
  669. return property_Location->size();
  670. }
  671. /**
  672. * remove the ith element, same as set_nil_at.
  673. */
  674. bool WSF_CALL
  675. AviaryCommon::ResourceLocation::removeLocationAt(int i)
  676. {
  677. return setLocationNilAt(i);
  678. }
  679. /**
  680. * resetter for location
  681. */
  682. bool WSF_CALL
  683. AviaryCommon::ResourceLocation::resetLocation()
  684. {
  685. int i = 0;
  686. int count = 0;
  687. if (property_Location != NULL)
  688. {
  689. std::vector<axutil_uri_t*>::iterator it = property_Location->begin();
  690. for( ; it < property_Location->end() ; ++it)
  691. {
  692. axutil_uri_t* element = *it;
  693. if(element != NULL)
  694. {
  695. axutil_uri_free(element, Environment::getEnv());
  696. element = NULL;
  697. }
  698. }
  699. }
  700. if(NULL != property_Location)
  701. delete property_Location;
  702. isValidLocation = false;
  703. return true;
  704. }
  705. /**
  706. * Check whether location is nill
  707. */
  708. bool WSF_CALL
  709. AviaryCommon::ResourceLocation::isLocationNil()
  710. {
  711. return !isValidLocation;
  712. }
  713. /**
  714. * Set location to nill (currently the same as reset)
  715. */
  716. bool WSF_CALL
  717. AviaryCommon::ResourceLocation::setLocationNil()
  718. {
  719. return resetLocation();
  720. }
  721. /**
  722. * Check whether location is nill at i
  723. */
  724. bool WSF_CALL
  725. AviaryCommon::ResourceLocation::isLocationNilAt(int i)
  726. {
  727. return (isValidLocation == false ||
  728. NULL == property_Location ||
  729. NULL == (*property_Location)[i]);
  730. }
  731. /**
  732. * Set location to nil at i
  733. */
  734. bool WSF_CALL
  735. AviaryCommon::ResourceLocation::setLocationNilAt(int i)
  736. {
  737. int size = 0;
  738. int j;
  739. bool non_nil_exists = false;
  740. int k = 0;
  741. if(property_Location == NULL ||
  742. isValidLocation == false)
  743. {
  744. non_nil_exists = false;
  745. }
  746. else
  747. {
  748. size = property_Location->size();
  749. for(j = 0, k = 0; j < size; j ++ )
  750. {
  751. if(i == j) continue;
  752. if(NULL != (*property_Location)[i])
  753. {
  754. k++;
  755. non_nil_exists = true;
  756. if( k >= 0)
  757. {
  758. break;
  759. }
  760. }
  761. }
  762. }
  763. if( k < 0)
  764. {
  765. WSF_LOG_ERROR_MSG(Environment::getEnv()->log, WSF_LOG_SI, "Size of the array of location is beinng set to be smaller than the specificed number of minOccurs(0)");
  766. return AXIS2_FAILURE;
  767. }
  768. if(property_Location == NULL)
  769. {
  770. isValidLocation = false;
  771. return true;
  772. }
  773. /* check whether there already exist an element */
  774. axutil_uri_t* element = (*property_Location)[i];
  775. if(NULL != element)
  776. {
  777. axutil_uri_free(element, Environment::getEnv());
  778. }
  779. if(!non_nil_exists)
  780. {
  781. isValidLocation = false;
  782. (*property_Location)[i] = NULL;
  783. return AXIS2_SUCCESS;
  784. }
  785. (*property_Location)[i] = NULL;
  786. return AXIS2_SUCCESS;
  787. }
  788. /**
  789. * Getter for status by Property Number 3
  790. */
  791. AviaryCommon::Status* WSF_CALL
  792. AviaryCommon::ResourceLocation::getProperty3()
  793. {
  794. return getStatus();
  795. }
  796. /**
  797. * getter for status.
  798. */
  799. AviaryCommon::Status* WSF_CALL
  800. AviaryCommon::ResourceLocation::getStatus()
  801. {
  802. return property_Status;
  803. }
  804. /**
  805. * setter for status
  806. */
  807. bool WSF_CALL
  808. AviaryCommon::ResourceLocation::setStatus(
  809. AviaryCommon::Status* arg_Status)
  810. {
  811. if(isValidStatus &&
  812. arg_Status == property_Status)
  813. {
  814. return true;
  815. }
  816. if(NULL == arg_Status)
  817. {
  818. WSF_LOG_ERROR_MSG( Environment::getEnv()->log,WSF_LOG_SI,"status is being set to NULL, but it is not a nullable element");
  819. return AXIS2_FAILURE;
  820. }
  821. resetStatus();
  822. if(NULL == arg_Status)
  823. {
  824. /* We are already done */
  825. return true;
  826. }
  827. property_Status = arg_Status;
  828. isValidStatus = true;
  829. return true;
  830. }
  831. /**
  832. * resetter for status
  833. */
  834. bool WSF_CALL
  835. AviaryCommon::ResourceLocation::resetStatus()
  836. {
  837. int i = 0;
  838. int count = 0;
  839. if(property_Status != NULL)
  840. {
  841. delete property_Status;
  842. }
  843. isValidStatus = false;
  844. return true;
  845. }
  846. /**
  847. * Check whether status is nill
  848. */
  849. bool WSF_CALL
  850. AviaryCommon::ResourceLocation::isStatusNil()
  851. {
  852. return !isValidStatus;
  853. }
  854. /**
  855. * Set status to nill (currently the same as reset)
  856. */
  857. bool WSF_CALL
  858. AviaryCommon::ResourceLocation::setStatusNil()
  859. {
  860. return resetStatus();
  861. }