Ejemplo n.º 1
0
 @Override
 public boolean next(TreeEvent event) {
   if (!finished) {
     SnmpUriResponse response = createResponse(event);
     finished |= callback.onResponse(response, url, event.getUserObject());
   }
   return !finished;
 }
Ejemplo n.º 2
0
 @Override
 public void finished(TreeEvent event) {
   if (!finished) {
     SnmpUriResponse response = createResponse(event);
     if (response.getResponseType() == SnmpUriResponse.Type.NEXT) {
       response.setResponseType(SnmpUriResponse.Type.FINAL);
     }
     callback.onResponse(response, url, event.getUserObject());
     finished = true;
   }
 }
Ejemplo n.º 3
0
 private SnmpUriResponse createResponse(TreeEvent event) {
   SnmpUriResponse response = new SnmpUriResponse(SnmpUriResponse.Type.TIMEOUT);
   if (event.getStatus() == TreeEvent.STATUS_OK) {
     VariableBinding[] vbs = event.getVariableBindings();
     int errorStatus = event.getStatus();
     response = new SnmpUriResponse(Collections.singletonList(vbs), errorStatus);
     if (errorStatus == PDU.noError) {
       response.setResponseType(SnmpUriResponse.Type.NEXT);
     }
   } else if (event.getStatus() == TreeEvent.STATUS_EXCEPTION) {
     response =
         new SnmpUriResponse(SnmpUriResponse.Type.IO_ERROR, event.getException().getMessage());
   } else if (event.getStatus() == TreeEvent.STATUS_REPORT) {
     response =
         new SnmpUriResponse(
             SnmpUriResponse.Type.SECURITY_ERROR,
             (event.getReportPDU().size() > 0
                 ? event.getReportPDU().get(0).toString()
                 : "<empty report PDU>"));
   } else if (event.getStatus() == TreeEvent.STATUS_WRONG_ORDER) {
     response = new SnmpUriResponse(SnmpUriResponse.Type.LEXICOGRAPHIC_ORDER_ERROR);
   }
   return response;
 }