summaryrefslogtreecommitdiff
path: root/modules/CIAO/ciao/Deployment/Handlers/CIAO_Handler_Common.cpp
blob: 3ea45b63aeaa7f3d26584c0b5d4d6730e9cc7590 (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
// $Id$
#include "CIAO_Handler_Common.h"

#include "Deployment/Deployment_PlanErrorC.h"
#include "ciao/Logger/Log_Macros.h"

namespace CIAO
{
  const char * 
  Deployment_Common::get_implementation (const char *name, 
                                         const ::Deployment::DeploymentPlan &plan)
  {
    if (name == 0)
      throw ::Deployment::PlanError (name,
                                     "No such artifact");
    
    for (CORBA::ULong i = 0;
         i < plan.artifact.length ();
         ++i)
      {
        if (ACE_OS::strcmp (plan.artifact[i].name.in (),
                            name) == 0)
          {
            if (plan.artifact[i].location.length () >= 1 &&
                plan.artifact[i].location[0] != 0)
              return plan.artifact[i].location[0].in ();
            else
              {
                CIAO_ERROR (1, (LM_ERROR, CLINFO
                                "Component_Handler_i::get_implementation - "
                                "No valid location for artifact <%C>\n",
                                name));
                throw ::Deployment::PlanError (name,
                                               "No valid location field\n");
              }
          }
      }

    CIAO_ERROR (1, (LM_ERROR, CLINFO
                    "Component_Handler_i::get_implementation - "
                    "Unable to locate artifact <%C>\n",
                    name));
    throw ::Deployment::PlanError (name,
                                   "Nonexistant artifact");
    return 0;
  } 
}