summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DnC/Config_Handlers/IAD_Handler.cpp
blob: ee38f3c1c4bf5fa1df2436d2f39749a4fc733251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
//==================================================================
/**
 *  @file  IAD_Handler.cpp
 *
 *  $Id$
 *
 *  @author Emre Turkay  <turkaye@dre.vanderbilt.edu>
 */
//=====================================================================

#ifndef IAD_HANDLER_C
#define IAD_HANDLER_C

#include "tao/Exception.h"
#include "ace/Auto_Ptr.h"
#include "ace/Log_Msg.h"

#include "Property_Handler.h"
#include "Requirement_Handler.h"
#include "PCI_Handler.h"
#include "CompIntrDesc_Handler.h"
#include "NIA_Handler.h"
#include "IAD_Handler.h"

#include <iostream>

using std::cerr;
using std::endl;

namespace CIAO
{
  namespace Config_Handler
  {
    IAD_Handler::IAD_Handler (DOMDocument* doc, unsigned long filter)
      : // traverse_ (doc),
        root_ (doc->getDocumentElement()),
        filter_ (filter),
        iter_ (doc->createNodeIterator (this->root_,
                                              this->filter_,
                                              0,
                                              true)),
        release_ (true)
    {}

    IAD_Handler::IAD_Handler (DOMNodeIterator* iter, bool release)
      : // traverse_ (0),
	root_ (0), filter_ (0), iter_ (iter), release_ (release)
    {}


    IAD_Handler::~IAD_Handler()
    {
      if (this->release_)
        this->iter_->release();
    }

    /// handle the package configuration and populate it
    void IAD_Handler::process_ImplementationArtifactDescription
      (::Deployment::ImplementationArtifactDescription &iad)
    {
      // This is bogus and should be replaced later.
      ACE_DECLARE_NEW_CORBA_ENV;

      for (DOMNode* node = this->iter_->nextNode();
           node != 0;
           node = this->iter_->nextNode())
        {
          XStr node_name (node->getNodeName());
          if (node_name == XStr (ACE_TEXT ("label")))
            {
              // Fetch the text node which contains the "label"
              node = this->iter_->nextNode();
              DOMText* text = ACE_reinterpret_cast (DOMText*, node);
              this->process_label (text->getNodeValue(), iad);
            }
          else if (node_name == XStr (ACE_TEXT ("UUID")))
            {
              // Fetch the text node which contains the "UUID"
              node = this->iter_->nextNode();
              DOMText* text = ACE_reinterpret_cast (DOMText*, node);
              this->process_UUID (text->getNodeValue(), iad);
            }
          else if (node_name == XStr (ACE_TEXT ("location")))
            {
              // Fetch the text node which contains the "location"
              node = this->iter_->nextNode();
              DOMText* text = ACE_reinterpret_cast (DOMText*, node);
              this->process_location (text->getNodeValue(), iad);
            }
          else if (node_name == XStr (ACE_TEXT ("execParameter")))
            {
              // increase the length of the sequence
              CORBA::ULong i (iad.execParameter.length ());
              iad.execParameter.length (i + 1);

              // delegate the populating process
              Property_Handler::process_Property (this->iter_,
                                                  iad.execParameter[i]);
            }
          else if (node_name == XStr (ACE_TEXT ("infoProperty")))
            {
              // increase the length of the sequence
              CORBA::ULong i (iad.infoProperty.length ());
              iad.infoProperty.length (i + 1);

              // delegate the populating process
              Property_Handler::process_Property (this->iter_,
                                                  iad.infoProperty[i]);
            }
          else if (node_name == XStr (ACE_TEXT ("deployRequirement")))
            {
              // increase the length of the sequence
              CORBA::ULong i (iad.deployRequirement.length ());
              iad.deployRequirement.length (i + 1);

              // delegate the populating process
              Requirement_Handler::process_Requirement (this->iter_,
							iad.deployRequirement[i]);
            }
          else if (node_name == XStr (ACE_TEXT ("dependsOn")))
            {
              // increase the length of the sequence
              CORBA::ULong i (iad.dependsOn.length ());
              iad.dependsOn.length (i + 1);

	      // fetch the NIA handler
	      NIA_Handler nia_handler (this->iter_, false);

              // delegate the populating process
	      nia_handler.process_NamedImplementationArtifact (iad.dependsOn[i]);
            }
          else
            {
              // ??? How did we get here ???
              ACE_THROW (CORBA::INTERNAL());
            }
        }
      return;
    }

    /// handle label attribute
    void IAD_Handler::process_label
      (const XMLCh* name, ::Deployment::ImplementationArtifactDescription &iad)
    {
      if (name)
        {
          iad.label = XMLString::transcode (name);
        }
    }

    /// handle UUID attribute
    void IAD_Handler::process_UUID
      (const XMLCh* name, ::Deployment::ImplementationArtifactDescription &iad)
    {
      if (name)
        {
          iad.UUID = XMLString::transcode (name);
        }
    }

    /// handle location attribute
    void IAD_Handler::process_location
      (const XMLCh* name, ::Deployment::ImplementationArtifactDescription &iad)
    {
      if (name)
        {
          iad.location = XMLString::transcode (name);
        }
    }

  }
}

#endif /* IAD_HANDLER_C */