1 karl 1.13 //%2006////////////////////////////////////////////////////////////////////////
|
2 bob 1.1 //
|
3 karl 1.10 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.8 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.10 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.11 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.13 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 bob 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.4 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 bob 1.1 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
|
21 kumpf 1.4 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 bob 1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.4 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 bob 1.1 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Bob Blair (bblair@bmc.com)
33 //
|
34 kumpf 1.6 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
35 // (carolann_graves@hp.com)
|
36 gerarda 1.7 // Gerarda Marquez (gmarquez@us.ibm.com)
37 // -- PEP 43 changes
|
38 kumpf 1.9 // Terry Martin, Hewlett-Packard Company (terry.martin@hp.com)
|
39 bob 1.1 //
40 //%/////////////////////////////////////////////////////////////////////////////
41
|
42 kumpf 1.9 #include <Pegasus/Common/Config.h>
43 #include <Pegasus/Common/CIMQualifierDecl.h>
44 #include <Pegasus/Common/CIMClass.h>
45 #include <Pegasus/Common/CIMInstance.h>
|
46 bob 1.1 #include "cimmofRepository.h"
47 #include "cimmofClient.h"
48 #include "cimmofParser.h"
49 #include "cimmofMessages.h"
|
50 kumpf 1.9 #include "cimmofRepositoryInterface.h"
|
51 bob 1.1
52 PEGASUS_USING_PEGASUS;
53
54 cimmofRepositoryInterface::cimmofRepositoryInterface() :
55 _repository(0),
56 _client(0),
57 _ot(compilerCommonDefs::USE_REPOSITORY)
58 {
59 }
60
61 cimmofRepositoryInterface::~cimmofRepositoryInterface() {
62 delete _repository;
63 delete _client;
64 }
65
66 void
67 cimmofRepositoryInterface::init(_repositoryType type, String location,
|
68 kumpf 1.15 Uint32 mode,
|
69 bob 1.1 compilerCommonDefs::operationType ot)
70 {
71 String message;
72 cimmofMessages::arglist arglist;
73 _ot = ot;
74 if (type == REPOSITORY_INTERFACE_LOCAL) {
75 // create a cimmofRepository object and put it in _repository
76 cimmofParser *p = cimmofParser::Instance();
77 const String NameSpace = p->getDefaultNamespacePath();
78 if (location != "") {
|
79 jim.wunderlich 1.12 try {
|
80 kumpf 1.15 _repository = new cimmofRepository(location, mode, _ot);
|
81 bob 1.1 } catch(Exception &e) {
82 arglist.append(location);
83 arglist.append(e.getMessage());
84 cimmofMessages::getMessage(message,
85 cimmofMessages::REPOSITORY_CREATE_ERROR,
86 arglist);
87 p->elog(message);
88 delete _repository;
89 _repository = 0;
90 }
91 }
92 } else if (type == REPOSITORY_INTERFACE_CLIENT) {
93 // create a CIMClient object and put it in _client
94 _client = new cimmofClient();
95 try {
96 _client->init(location, ot);
|
97 kumpf 1.5 } catch(Exception &e) {
|
98 bob 1.1 arglist.append(location);
99 arglist.append(e.getMessage());
100 cimmofMessages::getMessage(message,
101 cimmofMessages::REPOSITORY_CREATE_ERROR,
102 arglist);
103 cimmofParser *p = cimmofParser::Instance();
104 p->elog(message);
105 delete _client;
106 _client = 0;
107 }
108 } else {
109 // throw an exception
110 }
111 }
112
113 void
|
114 kumpf 1.6 cimmofRepositoryInterface::addClass(const CIMNamespaceName &nameSpace,
115 CIMClass &Class)
|
116 bob 1.1 const {
117 if (_repository)
118 _repository->addClass(nameSpace, &Class);
119 if (_client)
|
120 kumpf 1.2 _client->addClass(nameSpace, Class);
|
121 bob 1.1 }
122
123 void
|
124 kumpf 1.6 cimmofRepositoryInterface::addQualifier(const CIMNamespaceName &nameSpace,
|
125 bob 1.1 CIMQualifierDecl &qualifier) const
126 {
127 if (_repository)
128 _repository->addQualifier(nameSpace, &qualifier);
129 if (_client)
|
130 kumpf 1.5 _client->addQualifier(nameSpace, qualifier);
|
131 bob 1.1 }
132
133 void
|
134 kumpf 1.6 cimmofRepositoryInterface::addInstance(const CIMNamespaceName &nameSpace,
|
135 bob 1.1 CIMInstance &instance) const
136 {
137 if (_repository)
138 _repository->addInstance(nameSpace, &instance);
139 if (_client)
|
140 kumpf 1.5 _client->addInstance(nameSpace, instance);
|
141 bob 1.1 }
142
143 CIMQualifierDecl
|
144 kumpf 1.6 cimmofRepositoryInterface::getQualifierDecl(const CIMNamespaceName &nameSpace,
145 const CIMName &qualifierName) const
|
146 bob 1.1 {
147 if (_repository)
148 return (_repository->getQualifierDecl(nameSpace, qualifierName));
149 else if (_client)
|
150 kumpf 1.5 return (_client->getQualifierDecl(nameSpace, qualifierName));
|
151 bob 1.1 else
152 return CIMQualifierDecl();
153 }
154
155 CIMClass
|
156 kumpf 1.6 cimmofRepositoryInterface::getClass(const CIMNamespaceName &nameSpace,
157 const CIMName &className) const
|
158 bob 1.1 {
159 if (_repository)
160 return (_repository->getClass(nameSpace, className));
161 else if (_client)
|
162 kumpf 1.5 return (_client->getClass(nameSpace, className));
|
163 bob 1.1 else
164 return CIMClass();
|
165 gerarda 1.7 }
166
167 void
168 cimmofRepositoryInterface::modifyClass(const CIMNamespaceName &nameSpace,
169 CIMClass &Class)
170 const {
171 if (_repository)
172 {
173 _repository->modifyClass(nameSpace, &Class);
174 }
175 if (_client)
176 {
177 _client->modifyClass(nameSpace, Class);
178 }
|
179 bob 1.1 }
180
181 void
|
182 kumpf 1.6 cimmofRepositoryInterface::createNameSpace(
183 const CIMNamespaceName &nameSpace) const
|
184 bob 1.1 {
185 if (_repository)
186 _repository->createNameSpace(nameSpace);
187 else if (_client)
|
188 kumpf 1.3 {
|
189 kumpf 1.2 _client->createNameSpace(nameSpace);
|
190 kumpf 1.3 }
|
191 bob 1.1 }
|