From: Dave B. <bla...@us...> - 2012-04-11 15:44:22
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/wbem In directory vz-cvs-3.sog:/tmp/cvs-serv15918/src/org/sblim/cimclient/internal/wbem Modified Files: Tag: Experimental WBEMClientCIMXML.java Log Message: 3516848 - enumerateNamespaces() method to WBEMClient Index: WBEMClientCIMXML.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/wbem/WBEMClientCIMXML.java,v retrieving revision 1.21.2.58 retrieving revision 1.21.2.59 diff -u -d -r1.21.2.58 -r1.21.2.59 --- WBEMClientCIMXML.java 5 Apr 2012 13:16:54 -0000 1.21.2.58 +++ WBEMClientCIMXML.java 11 Apr 2012 15:44:20 -0000 1.21.2.59 @@ -60,6 +60,7 @@ * 3514537 2012-04-03 blaschke-oss TCK: execQueryInstances requires boolean, not Boolean * 3514685 2012-04-03 blaschke-oss TCK: getProperty must return default values * 3515180 2012-04-05 blaschke-oss JSR48 log dir/file should handle UNIX/Win separators + * 3516848 2012-04-11 blaschke-oss enumerateNamespaces() method to WBEMClient */ package org.sblim.cimclient.internal.wbem; @@ -175,6 +176,8 @@ private volatile boolean iClosed = false; + private String iInteropNamespace = null; + /** * Ctor. */ @@ -1084,6 +1087,56 @@ } } + // DSP1033 states that CIMOMs shall include an Interop Namespace and that + // the name of this Interop Namespace shall be either "interop" (preferred) + // or "root/interop" while OpenPegasus 2.11 and earlier implemented + // "root/PG_InterOp" prior to adopting DSP1033. + private static final String[] InteropNamespaces = { "interop", "root/interop", + "root/PG_InterOp" }; + + private CloseableIterator<CIMObjectPath> enumerateNamespace(String pNamespace) { + if (pNamespace != null && pNamespace.trim().length() > 0) { + try { + CloseableIterator<CIMObjectPath> result = enumerateInstanceNames(new CIMObjectPath( + "CIM_Namespace", pNamespace)); + if (result != null) return result; + } catch (Exception e) { + // namespace may not exist + } + } + return null; + } + + public CloseableIterator<CIMObjectPath> enumerateNamespaces(String pNamespace) + throws WBEMException { + CloseableIterator<CIMObjectPath> result; + + // First, try the user's specified namespace (if any) + if (pNamespace != null && pNamespace.trim().length() > 0) { + result = enumerateNamespace(pNamespace); + if (result != null) return result; + } + + // Second, try the saved interop namespace (if any) + if (this.iInteropNamespace != null) { + result = enumerateNamespace(this.iInteropNamespace); + if (result != null) return result; + this.iInteropNamespace = null; + } + + // Finally, try the default interop namespace names + for (int i = 0; i < InteropNamespaces.length; i++) { + result = enumerateNamespace(InteropNamespaces[i]); + if (result != null) { + if (this.iInteropNamespace == null) this.iInteropNamespace = InteropNamespaces[i]; + return result; + } + } + + throw new WBEMException(WBEMException.CIM_ERR_FAILED, + "Interop namespaces do not exist, CIMOM may not support DSP1033"); + } + public CloseableIterator<CIMQualifierType<?>> enumerateQualifierTypes(CIMObjectPath pPath) throws WBEMException { |