00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00036 #include "OW_config.h"
00037 #include "OW_XMLCIMFactory.hpp"
00038 #include "OW_XMLClass.hpp"
00039 #include "OW_String.hpp"
00040 #include "OW_CIMClass.hpp"
00041 #include "OW_CIMInstance.hpp"
00042 #include "OW_CIMProperty.hpp"
00043 #include "OW_CIMValue.hpp"
00044 #include "OW_CIMUrl.hpp"
00045 #include "OW_CIMXMLParser.hpp"
00046 #include "OW_CIMObjectPath.hpp"
00047 #include "OW_Format.hpp"
00048 #include "OW_CIMException.hpp"
00049
00050 namespace OW_NAMESPACE
00051 {
00052
00053 namespace XMLClass
00054 {
00056 String
00057 getNameSpace(CIMXMLParser& parser)
00058 {
00059 String nameSpace;
00060 bool firstTime = true;
00061 while (parser.tokenIsId(CIMXMLParser::E_NAMESPACE))
00062 {
00063 String pname = parser.mustGetAttribute(CIMXMLParser::A_NAME);
00064 if (pname.empty())
00065 {
00066
00067
00068
00069 }
00070 else if (firstTime)
00071 {
00072 firstTime=false;
00073 nameSpace += pname;
00074 }
00075 else
00076 {
00077 nameSpace += "/" + pname;
00078 }
00079 parser.mustGetNextTag();
00080 parser.mustGetEndTag();
00081 }
00082 return nameSpace;
00083 }
00085 CIMObjectPath
00086 getObjectWithPath(CIMXMLParser& parser, CIMClass& c,
00087 CIMInstance& i)
00088 {
00089 CIMXMLParser::tokenId token = parser.getToken();
00090 parser.mustGetChild();
00091
00092 if (token == CIMXMLParser::E_VALUE_OBJECTWITHPATH)
00093 {
00094 token = parser.getToken();
00095
00096 CIMObjectPath tmpcop = XMLCIMFactory::createObjectPath(parser);
00097
00098 if (token == CIMXMLParser::E_CLASSPATH)
00099 {
00100 parser.mustTokenIsId(CIMXMLParser::E_CLASS);
00101 c = readClass(parser,tmpcop);
00102 }
00103 else if (token==CIMXMLParser::E_INSTANCEPATH)
00104 {
00105 parser.mustTokenIsId(CIMXMLParser::E_INSTANCE);
00106 i = readInstance(parser,tmpcop);
00107 i.setNameSpace(tmpcop.getNameSpace());
00108 }
00109 else
00110 {
00111 OW_THROWCIMMSG(CIMException::FAILED,
00112 Format("Require instance or class in object with path declaration. token = %1, parser = %2", token, parser).c_str());
00113 }
00114
00115 parser.mustGetEndTag();
00116 return tmpcop;
00117 }
00118 else if (token==CIMXMLParser::E_VALUE_OBJECTWITHLOCALPATH)
00119 {
00120 token = parser.getToken();
00121 CIMObjectPath tmpcop = XMLCIMFactory::createObjectPath(parser);
00122
00123 if (token == CIMXMLParser::E_LOCALCLASSPATH)
00124 {
00125 parser.mustTokenIsId(CIMXMLParser::E_CLASS);
00126 c = readClass(parser, tmpcop);
00127 }
00128 else if (token == CIMXMLParser::E_LOCALINSTANCEPATH)
00129 {
00130 parser.mustTokenIsId(CIMXMLParser::E_INSTANCE);
00131 i = readInstance(parser, tmpcop);
00132 i.setNameSpace(tmpcop.getNameSpace());
00133 }
00134 else
00135 {
00136 OW_THROWCIMMSG(CIMException::FAILED,
00137 "Require instance or class in object with path declaration");
00138 }
00139
00140 parser.mustGetEndTag();
00141 return tmpcop;
00142 }
00143 OW_THROWCIMMSG(CIMException::FAILED,
00144 Format("Require instance or class in object with path declaration. token = %1, parser = %2", token, parser).c_str());
00145 }
00147 CIMClass
00148 readClass(CIMXMLParser& childNode, CIMObjectPath& path)
00149 {
00150 CIMClass cimClass = XMLCIMFactory::createClass(childNode);
00151 path.setClassName(cimClass.getName());
00152 return cimClass;
00153 }
00155 CIMInstance
00156 readInstance(CIMXMLParser& childNode, CIMObjectPath& path)
00157 {
00158 CIMInstance cimInstance = XMLCIMFactory::createInstance(childNode);
00159 return cimInstance;
00160 }
00161
00162 }
00163 }
00164