Package com.dgwave.osrs.resp

Examples of com.dgwave.osrs.resp.OsrsResponse


*/
public class OsrsResponseFactory {

  public OsrsResponse createResponse(OsrsRequest request, OPSEnvelope resp) throws OsrsException {
   
    OsrsResponse response = createOsrsResponse(request.getModel());
   
    if (resp == null) { //nothing came
      response.setError(true);
      return response;
    }
    // find error code and populate
   
    DtAssoc dt = (DtAssoc) resp.getBody().getDataBlock().getDtAass().get(0);
    List<Object> items = dt.getDtAassi();
    for (Iterator<Object> iterator = items.iterator(); iterator.hasNext();) {
      Object object = (Object) iterator.next();
      if (object instanceof Item) {
        Item item = (Item) object;
        if ("action".equals(item.getKey())) {
          response.setAction(item.getStringValue());
        } else if ("object".equals(item.getKey())) {
          response.setObject(item.getStringValue());
        } else if ("response_text".equals(item.getKey())) {
          response.setErrorMessage(item.getStringValue());
        } else if ("response_code".equals(item.getKey())) {
          try {
            response.setErrorCode(Integer.parseInt(item.getStringValue()));
          } catch (NumberFormatException e) {
            response.setErrorCode(999);
          }
        } else if ("is_success".equals(item.getKey())) {
          int tf = Integer.parseInt(item.getStringValue());
          response.setError(tf==1?false:true);
        } else if ("protocol".equals(item.getKey())) {
          response.setProtocol(item.getStringValue());
        }else  {
          populate(response, item);
        }
      }
    }
View Full Code Here


  public OsrsResponse sendReceive(OsrsRequest request) throws OsrsException {

    String ret = sendReceive(getString(request));
    OPSEnvelope resp = createEnvelope(ret);
    OsrsResponse response = orf.createResponse(request, resp);
      return response;
  }
View Full Code Here

        clayy = Class.forName("java.util.List");
      } else {
        clayy = Class.forName("com.dgwave.osrs.model." + model);
      }
      Method method = clazz.getDeclaredMethod("set"+model, clayy);
        OsrsResponse r = (OsrsResponse)clazz.newInstance();
      if (r != null) {
        Object m = null;
        if (model.endsWith("s")) {
          m = new ArrayList<Object>();
        } else {
View Full Code Here

  @Test
  public void testSendReceive() {
    try {
      BelongsToRsp req = new BelongsToRsp();
      req.setDomain(new Domain("dgwave.com"));     
      OsrsResponse response = client.sendReceive(req);
      assertNotNull(response);
      System.out.println(response);   
    } catch (OsrsException e) {
      e.printStackTrace();
      fail ("Error while creating string from request");
View Full Code Here

  @Test
  public void testGetBalance() {
    try {
      GetBalance req = new GetBalance();
      req.setRegistrantIp(null);     
      OsrsResponse response = client.sendReceive(req);
      assertNotNull(response);
      System.out.println(response);
     
      Balance balance = ((BalanceResponse)response).getBalance();
      System.out.println("Balance is: " + balance.getBalance());
View Full Code Here

  public void testGetDeleteDomains() {
    try {
      GetDeletedDomains req = new GetDeletedDomains();
      DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      req.setDeletedTo(dfm.parse("2031-09-04 13:00:00"));
      OsrsResponse response = client.sendReceive(req);
      assertNotNull(response);
      System.out.println(response);
     
      List<DeletedDomain> delDomainList = ((DeletedDomainsResponse)response).getDeletedDomains();
      System.out.println("Number in deleted domain list is: " + delDomainList.size());
View Full Code Here

TOP

Related Classes of com.dgwave.osrs.resp.OsrsResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.