~scarneiro/ubuntu/oneiric/opendrim-lmp-recordlog/fix-for-756108

« back to all changes in this revision

Viewing changes to OpenDRIM_LogManagesRecord/assocOpenDRIM_LogManagesRecord.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Guillaume BOTTEX
  • Date: 2009-08-19 17:08:36 UTC
  • Revision ID: james.westby@ubuntu.com-20090819170836-4pdxix40ulw5xqds
Tags: upstream-1.1.1
ImportĀ upstreamĀ versionĀ 1.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*###############################################################################
 
2
# Linux Management Providers (LMP), OpenDRIM_RecordLogPackage provider package
 
3
# Copyright (C) 2007 Ilsoo Byun, ETRI <widepis@etri.re.kr, widepis@empal.com>
 
4
 
5
# This program is being developed under the "OpenDRIM" project.
 
6
# The "OpenDRIM" project web page: http://opendrim.sourceforge.net
 
7
# The "OpenDRIM" project mailing list: opendrim@googlegroups.com
 
8
 
9
# This program is free software; you can redistribute it and/or
 
10
# modify it under the terms of the GNU General Public License
 
11
# as published by the Free Software Foundation; version 2
 
12
# of the License.
 
13
 
14
# This program is distributed in the hope that it will be useful,
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
# GNU General Public License for more details.
 
18
 
19
# You should have received a copy of the GNU General Public License
 
20
# along with this program; if not, write to the Free Software
 
21
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
22
#################################################################################
 
23
 
 
24
#################################################################################
 
25
# To contributors, please leave your contact information in this section
 
26
# AND comment your changes in the source code.
 
27
 
28
# Modified by 2008 Guillaume BOTTEX, ETRI <guillaumebottex@etri.re.kr, guillaumebottex@gmail.com>
 
29
###############################################################################*/
 
30
 
 
31
#include "assocOpenDRIM_LogManagesRecord.h"
 
32
 
 
33
int OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_associatorFilter(const CMPIBroker* broker, const CMPIContext* ctx, const CMPIObjectPath* cop, Instance& knownInstance, const char* assocClass, const char* resultClass, const char* role, const char* resultRole, bool& leftToRight, string& errorMessage) {
 
34
        _E_;
 
35
        string _assocClass, _resultClass, _resultRole, _role;
 
36
        assocClass == NULL ? _assocClass = "null" : _assocClass = assocClass;
 
37
        resultClass == NULL ? _resultClass = "null" : _resultClass = resultClass;
 
38
        resultRole == NULL ?  _resultRole = "null" :  _resultRole = resultRole;
 
39
        role == NULL ?  _role = "null" :  _role = role;
 
40
        
 
41
        _DEBUG(CF_intToStr(sizeof(OpenDRIM_LogManagesRecord_classnames)/sizeof(char*)));
 
42
        for (unsigned int i=0; i<sizeof(OpenDRIM_LogManagesRecord_classnames)/sizeof(char*); i++) {
 
43
                if (CF_strCmpNoCase(_assocClass, OpenDRIM_LogManagesRecord_classnames[i])) {
 
44
                        _assocClass=OpenDRIM_LogManagesRecord_classnames[0];
 
45
                        break;
 
46
                }
 
47
        }
 
48
        if (!CF_strCmpNoCase(_assocClass, "null") && !CF_strCmpNoCase(_assocClass, OpenDRIM_LogManagesRecord_classnames[0]))
 
49
                return OK;
 
50
        
 
51
        Objectpath known(broker, (CMPIObjectPath*) cop);
 
52
        int errorCode = CA_associatorResolveDirection(broker, Record_classnames, Log_classnames, Record_NAMESPACE, Log_NAMESPACE, Record_role, Log_role, known, _resultClass, _role, _resultRole, leftToRight);
 
53
        if (errorCode != OK)
 
54
                return -1;
 
55
        
 
56
        if (leftToRight) {
 
57
                CF_assert(OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_getRecord(broker, ctx, known, knownInstance, NULL, errorMessage));
 
58
        } else {
 
59
                CF_assert(OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_getLog(broker, ctx, known, knownInstance, NULL, errorMessage));
 
60
        }
 
61
        _L_;
 
62
        return OK;
 
63
}
 
64
 
 
65
int OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_associator(const CMPIBroker* broker, const CMPIContext* ctx, const CMPIObjectPath* cop, Instance& knownInstance, const char* assocClass, const char* resultClass, const char* role, const char* resultRole, const char** properties, vector<Instance>& associatedInstances, bool& leftToRight, string& errorMessage, const string& dicriminant) {
 
66
        _E_;
 
67
        int errorCode = OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_associatorFilter(broker, ctx, cop, knownInstance, assocClass, resultClass, role, resultRole, leftToRight, errorMessage);
 
68
        if (errorCode == -1)
 
69
                return OK;
 
70
        if (errorCode != OK)
 
71
                return errorCode;
 
72
        
 
73
        if (leftToRight) {
 
74
                if (role != NULL && strcasecmp(role, "Record") != 0) return OK;
 
75
                if (resultRole != NULL && strcasecmp(resultRole, "Log") != 0) return OK;
 
76
                CF_assert(OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_associatorRecordToLog(broker, ctx, knownInstance, properties, associatedInstances, errorMessage, dicriminant));
 
77
        } else {
 
78
                if (role != NULL && strcasecmp(role, "Log") != 0) return OK;
 
79
                if (resultRole != NULL && strcasecmp(resultRole, "Record") != 0) return OK;
 
80
                CF_assert(OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_associatorLogToRecord(broker, ctx, knownInstance, properties, associatedInstances, errorMessage, dicriminant));
 
81
        }
 
82
        _L_;
 
83
        return OK;
 
84
}
 
85
 
 
86
int OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_enumerateRecords(const CMPIBroker* broker, const CMPIContext* ctx, vector<Instance>& instances, const char** properties, bool onlyNames, string& errorMessage) {
 
87
        _E_;
 
88
        /*
 
89
         * CMPI broker version
 
90
         */
 
91
        if (onlyNames) {
 
92
                vector<Objectpath> objectpaths;
 
93
                CF_assert(CB_enumerateInstanceNames(broker, ctx, Record_NAMESPACE, Record_classnames[0], objectpaths, errorMessage));
 
94
                for (size_t i=0; i<objectpaths.size(); i++)
 
95
                        instances.push_back(Instance(broker, objectpaths[i]));
 
96
        } else {
 
97
                CF_assert(CB_enumerateInstances(broker,ctx, Record_NAMESPACE, Record_classnames[0], properties, instances, errorMessage));
 
98
        }
 
99
        /*
 
100
         * Direct Invocation version
 
101
         */
 
102
        /*
 
103
        vector<CIM_RecordForLog> _instances;
 
104
        if (onlyNames) {
 
105
                CF_assert(OpenDRIM_RecordLogPackage_CIM_RecordForLog_retrieve(broker, ctx, _instances, properties, errorMessage, "ein"));
 
106
        } else {
 
107
                CF_assert(OpenDRIM_RecordLogPackage_CIM_RecordForLog_retrieve(broker, ctx, _instances, properties, errorMessage, "ei"));
 
108
        }
 
109
 
 
110
        for (size_t i=0; i<_instances.size(); i++)
 
111
                instances.push_back(Instance(broker, OpenDRIM_RecordLogPackage_CIM_RecordForLog_toCMPIInstance(broker, _instances[i])));
 
112
        */
 
113
        _L_;
 
114
        return OK;
 
115
}
 
116
 
 
117
int OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_getRecord(const CMPIBroker* broker, const CMPIContext* ctx, const Objectpath& objectpath, Instance& instance, const char** properties, string& errorMessage) {
 
118
        _E_;
 
119
        if (!CF_strCmpNoCase(objectpath.getClassname(), Record_classnames[0]))
 
120
                return INVALID_CLASS;
 
121
        //if (!CF_strCmpNoCase(objectpath.getNamespace(), Record_NAMESPACE))
 
122
        //      return INVALID_NAMESPACE;
 
123
        /*
 
124
         * CMPI broker version
 
125
         */
 
126
        CF_assert(CB_getInstance(broker, ctx, objectpath, properties, instance, errorMessage));
 
127
        
 
128
        /*
 
129
         * Direct Invocation version
 
130
         */
 
131
        /*
 
132
        CIM_RecordForLog _instance;
 
133
        OpenDRIM_RecordLogPackage_CIM_RecordForLog_toCPP(broker, objectpath.getHdl(), _instance);
 
134
        CF_assert(OpenDRIM_RecordLogPackage_CIM_RecordForLog_getInstance(broker, ctx, _instance, properties, errorMessage));
 
135
        instance = Instance(broker, OpenDRIM_RecordLogPackage_CIM_RecordForLog_toCMPIInstance(broker, _instance));
 
136
        */
 
137
        _L_;
 
138
        return OK;
 
139
}
 
140
 
 
141
int OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_enumerateLogs(const CMPIBroker* broker, const CMPIContext* ctx, vector<Instance>& instances, const char** properties, bool onlyNames, string& errorMessage) {
 
142
        _E_;
 
143
        /*
 
144
         * CMPI broker version
 
145
         */
 
146
        if (onlyNames) {
 
147
                vector<Objectpath> objectpaths;
 
148
                CF_assert(CB_enumerateInstanceNames(broker, ctx, Log_NAMESPACE, Log_classnames[0], objectpaths, errorMessage));
 
149
                for (size_t i=0; i<objectpaths.size(); i++)
 
150
                        instances.push_back(Instance(broker, objectpaths[i]));
 
151
        } else {
 
152
                CF_assert(CB_enumerateInstances(broker,ctx, Log_NAMESPACE, Log_classnames[0], properties, instances, errorMessage));
 
153
        }
 
154
        /*
 
155
         * Direct Invocation version
 
156
         */
 
157
        /*
 
158
        vector<CIM_Log> _instances;
 
159
        if (onlyNames) {
 
160
                CF_assert(OpenDRIM_RecordLogPackage_CIM_Log_retrieve(broker, ctx, _instances, properties, errorMessage, "ein"));
 
161
        } else {
 
162
                CF_assert(OpenDRIM_RecordLogPackage_CIM_Log_retrieve(broker, ctx, _instances, properties, errorMessage, "ei"));
 
163
        }
 
164
 
 
165
        for (size_t i=0; i<_instances.size(); i++)
 
166
                instances.push_back(Instance(broker, OpenDRIM_RecordLogPackage_CIM_Log_toCMPIInstance(broker, _instances[i])));
 
167
        */
 
168
        _L_;
 
169
        return OK;
 
170
}
 
171
 
 
172
int OpenDRIM_RecordLogPackage_OpenDRIM_LogManagesRecord_getLog(const CMPIBroker* broker, const CMPIContext* ctx, const Objectpath& objectpath, Instance& instance, const char** properties, string& errorMessage) {
 
173
        _E_;
 
174
        if (!CF_strCmpNoCase(objectpath.getClassname(), Log_classnames[0]))
 
175
                return INVALID_CLASS;
 
176
        //if (!CF_strCmpNoCase(objectpath.getNamespace(), Log_NAMESPACE))
 
177
        //      return INVALID_NAMESPACE;
 
178
        /*
 
179
         * CMPI broker version
 
180
         */
 
181
        CF_assert(CB_getInstance(broker, ctx, objectpath, properties, instance, errorMessage));
 
182
 
 
183
        /*
 
184
         * Direct Invocation version
 
185
         */
 
186
        /*
 
187
        CIM_Log _instance;
 
188
        OpenDRIM_RecordLogPackage_CIM_Log_toCPP(broker, objectpath.getHdl(), _instance);
 
189
        CF_assert(OpenDRIM_RecordLogPackage_CIM_Log_getInstance(broker, ctx, _instance, properties, errorMessage));
 
190
        instance = Instance(broker, OpenDRIM_RecordLogPackage_CIM_Log_toCMPIInstance(broker, _instance));
 
191
        */
 
192
        _L_;
 
193
        return OK;
 
194
}