jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibOid.java
changeset 22331 f65a493da643
parent 14677 1607f4cfc506
child 23010 6dadb192ad81
equal deleted inserted replaced
22330:cafb826672bd 22331:f65a493da643
   158         if (handlers == null)
   158         if (handlers == null)
   159             throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr);
   159             throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr);
   160 
   160 
   161         if (depth > length) {
   161         if (depth > length) {
   162             // Nothing is left... the oid is not valid
   162             // Nothing is left... the oid is not valid
   163             throw noSuchObjectException;
   163             throw new SnmpStatusException(SnmpStatusException.noSuchObject);
   164 
       
   165         } else if (depth == length) {
   164         } else if (depth == length) {
   166             // The oid is not complete...
   165             // The oid is not complete...
   167             throw noSuchInstanceException;
   166             throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
   168 
       
   169         } else {
   167         } else {
   170             // Some children variable or subobject is being querried
   168             // Some children variable or subobject is being querried
   171             // getChild() will raise an exception if no child is found.
   169             // getChild() will raise an exception if no child is found.
   172             //
   170             //
   173             final SnmpMibNode child= getChild(oid[depth]);
   171             final SnmpMibNode child= getChild(oid[depth]);
   203 
   201 
   204 
   202 
   205         final int length = oid.length;
   203         final int length = oid.length;
   206         SnmpMibNode node = null;
   204         SnmpMibNode node = null;
   207         long[] result = null;
   205         long[] result = null;
   208         if (handlers == null)
   206         if (handlers == null) {
   209             // This should be considered as a genErr, but we do not want to
   207             // This should be considered as a genErr, but we do not want to
   210             // abort the whole request, so we're going to throw
   208             // abort the whole request, so we're going to throw
   211             // a noSuchObject...
   209             // a noSuchObject...
   212             //
   210             //
   213             throw noSuchObjectException;
   211             throw new SnmpStatusException(SnmpStatusException.noSuchObject);
       
   212         }
   214 
   213 
   215         final Object data = handlers.getUserData();
   214         final Object data = handlers.getUserData();
   216         final int pduVersion = handlers.getRequestPduVersion();
   215         final int pduVersion = handlers.getRequestPduVersion();
   217 
   216 
   218         if (pos >= length) {
   217         if (pos >= length) {
   233             try {
   232             try {
   234                 final SnmpMibNode child = getChild(index);
   233                 final SnmpMibNode child = getChild(index);
   235                 // SnmpOid result = null;
   234                 // SnmpOid result = null;
   236                 if (child == null) {
   235                 if (child == null) {
   237                     // shouldn't happen
   236                     // shouldn't happen
   238                     throw noSuchObjectException;
   237                     throw new SnmpStatusException(SnmpStatusException.noSuchObject);
   239                     // validateVarId(index);
   238                     // validateVarId(index);
   240                     // handlers.add(this,varbind,depth);
   239                     // handlers.add(this,varbind,depth);
   241                     // result = new SnmpOid(0);
   240                     // result = new SnmpOid(0);
   242                 } else {
   241                 } else {
   243                     checker.add(depth, index);
   242                     checker.add(depth, index);
   442     SnmpMibNode getChild(long id) throws SnmpStatusException {
   441     SnmpMibNode getChild(long id) throws SnmpStatusException {
   443 
   442 
   444         // first we need to retrieve the identifier in the list of children
   443         // first we need to retrieve the identifier in the list of children
   445         //
   444         //
   446         final int pos= getInsertAt(id);
   445         final int pos= getInsertAt(id);
   447         if (pos >= nbChildren)
   446         if (pos >= nbChildren) {
   448             throw noSuchObjectException;
   447             throw new SnmpStatusException(SnmpStatusException.noSuchObject);
   449 
   448         }
   450         if (varList[pos] != (int) id)
   449 
   451             throw noSuchObjectException;
   450         if (varList[pos] != (int) id) {
       
   451             throw new SnmpStatusException(SnmpStatusException.noSuchObject);
       
   452         }
   452 
   453 
   453         // Access the node
   454         // Access the node
   454         //
   455         //
   455         SnmpMibNode child = null;
   456         SnmpMibNode child = null;
   456         try {
   457         try {
   457             child = children.elementAtNonSync(pos);
   458             child = children.elementAtNonSync(pos);
   458         } catch(ArrayIndexOutOfBoundsException e) {
   459         } catch(ArrayIndexOutOfBoundsException e) {
   459             throw noSuchObjectException;
   460             throw new SnmpStatusException(SnmpStatusException.noSuchObject);
   460         }
   461         }
   461         if (child == null)
   462         if (child == null) {
   462             throw noSuchInstanceException;
   463             throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
       
   464         }
   463         return child;
   465         return child;
   464     }
   466     }
   465 
   467 
   466     private int retrieveIndex(long val) {
   468     private int retrieveIndex(long val) {
   467 
   469