Package siena

Examples of siena.SienaException


  @SuppressWarnings("unchecked")
  private <T> List<T> sendAndParse(Document request) {
    Document response = send(request);
    Element root = response.getRootElement();
    if("error".equals(root.getName())) {
      throw new SienaException(root.attributeValue("class") + " " +root.getText());
    }
    List<Element> result = response.getRootElement().elements("object");
    List<T> list = new ArrayList<T>(result.size());
    for (Element element : result) {
      list.add((T) Common.parseEntity(element, null));
View Full Code Here


      checkDomain(domainBuf.toString());
      req.setConsistentRead(isReadConsistent());
      SelectResult res = sdb.select(req);
      return SdbMappingUtils.mapSelectResultToCount(res);
    }catch(AmazonClientException ex){
      throw new SienaException(ex);
    }
  }
View Full Code Here

 
  protected final int MAX_DEPTH = 25;
 
  protected <T> void doFetchList(Query<T> query, int limit, int offset, List<T> resList, int depth) {
    if(depth >= MAX_DEPTH){
      throw new SienaException("Reached maximum depth of recursion when retrieving more data ("+MAX_DEPTH+")");
    }
     
    preFetch(query, limit, offset, !resList.isEmpty());
   
    QueryOptionSdbContext sdbCtx = (QueryOptionSdbContext)query.option(QueryOptionSdbContext.ID);
View Full Code Here

          new BatchDeleteAttributesRequest(
            domain,
            doList.subList(i, sz)));     
      }
    }catch(AmazonClientException ex){
      throw new SienaException(ex);
    }
    return nb;
  }
View Full Code Here

      if(key != null) {
        // TODO: cutom exception message if time is null
        long time = Long.parseLong(root.attributeValue("time"));
        String hash = root.attributeValue("hash");
        if(!Util.sha1(time+key).equals(hash)) {
          throw new SienaException("Invalid hash");
        }
        long diff = Math.abs(time - System.currentTimeMillis());
        if(diff > 10000) {
          throw new SienaException("Invalid time");
        }
      }
      String action = root.getName();
      if("insert".equals(action)) {
        Model obj = parseEntity(root, classLoader);
View Full Code Here

      field.setAccessible(true);
      Object value;
      try {
        value = field.get(obj);
      } catch (Exception e) {
        throw new SienaException(e);
      }
      Class<?> type = field.getType();
      if(ClassInfo.isModel(type)) {
        Element f = element.addElement("object");
        f.addAttribute("name", field.getName());
View Full Code Here

    Model obj = null;
    try {
      Class<?> clazz = classForName(clazzName, classLoader);
      obj = (Model) clazz.newInstance();
    } catch(Exception e) {
      throw new SienaException("Error while trying to create an instance of "+clazzName+". "+e.getMessage());
    }
    parseEntity(obj, element, classLoader);
    return obj;
  }
View Full Code Here

        message += ", value: "+value+" ["+value.getClass().getName()+"]";
      } else {
        message += ", value: null";
      }
      message += ")";
      throw new SienaException(message, e);
    }
  }
View Full Code Here

 
  public void configure(Properties p) {
    try {
      backend = new URL(p.getProperty("backend"));
    } catch (MalformedURLException e) {
      throw new SienaException(e);
    }
  }
View Full Code Here

        for(Field field: fieldMap.keySet()){
          Map<Key, Entity> entities = ds.get(fieldMap.get(field));
          entityMap.put(field, entities);
        }
      }catch(Exception ex){
        throw new SienaException(ex);
      }
      // associates linked models to their models
      // linkedModels is just a map to contain entities already mapped
      Map<Key, Object> linkedModels = new HashMap<Key, Object>();
      Object linkedObj;
      Entity entity;
     
      for(Field field: fieldMap.keySet()){
        Object objVal = field.get(model);
        Key key = GaeMappingUtils.getKey(objVal);
        linkedObj = linkedModels.get(key);
        if(linkedObj==null){
          entity = entityMap.get(field).get(key);
          linkedObj = objVal;
          GaeMappingUtils.fillModel(linkedObj, entity);
          linkedModels.put(key, linkedObj);
        }
     
        field.set(model, linkedObj);       
      }

      return model;
    } catch(IllegalAccessException ex){
      throw new SienaException(ex);
    }   
  }
View Full Code Here

TOP

Related Classes of siena.SienaException

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.