Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.Blob


  public static void setProperty(Entity entity, String name, byte[] value) {
    if (value == null) {
      entity.setProperty(name, null);
    }
    else {
      entity.setProperty(name, new Blob(value));
    }
  }
View Full Code Here


    if (value == null) {
      entity.setUnindexedProperty(name, null);
    }
    else {
      entity.setUnindexedProperty(name,
          new Blob(StreamUtil.toBytes(value)));
    }
  }
View Full Code Here

    }
  }

  private boolean fetchClosingPricesForContract(String contractid, boolean setArchive) {

    Blob b = storeCSVfile(contractid);
    boolean fetchedCSV = fetchContractClosingPricesCSV(b, contractid);
    if (!fetchedCSV) {
      // If we should not archive this, and there was a problem with the
      // CSV do not do anything else
      if (!setArchive)
View Full Code Here

              value = new Text(s);
          } else if (value instanceof byte[]) {
            byte[] arr = (byte[]) value;
            // GAE Blob doesn't accept more than 1MB
            if (arr.length < 1000000)
              value = new Blob(arr);
            else
              value = new Blob(Arrays.copyOf(arr, 1000000));
          }
          else if (ClassInfo.isEmbedded(field)) {
            Embedded embed = field.getAnnotation(Embedded.class);
            switch(embed.mode()){
            case SERIALIZE_JSON:
              value = JsonSerializer.serialize(value).toString();
              String s = (String) value;
              if (s.length() > 500)
                value = new Text(s);
              break;
            case SERIALIZE_JAVA:
              // this embedding mode doesn't manage @EmbedIgnores
              try {
                byte[] b = JavaSerializer.serialize(value);
                // if length is less than 1Mb, can store in a blob else???
                if(b.length <= 1000000){
                  value = new Blob(b);
                }else{
                  throw new SienaException("object can be java serialized because it's too large >1mb");
                }               
              }
              catch(IOException ex) {
View Full Code Here

            propValue = new Text(s);
        } else if (propValue instanceof byte[]) {
          byte[] arr = (byte[]) propValue;
          // GAE Blob doesn't accept more than 1MB
          if (arr.length < 1000000)
            propValue = new Blob(arr);
          else
            propValue = new Blob(Arrays.copyOf(arr, 1000000));
        }
        else if (ClassInfo.isEmbedded(f)) {
          Embedded embed = f.getAnnotation(Embedded.class);
          switch(embed.mode()){
          case SERIALIZE_JSON:
            propValue = JsonSerializer.serialize(propValue).toString();
            String s = (String) propValue;
            if (s.length() > 500)
              propValue = new Text(s);
            break;
          case SERIALIZE_JAVA:
            // this embedding mode doesn't manage @EmbedIgnores
            try {
              byte[] b = JavaSerializer.serialize(propValue);
              // if length is less than 1Mb, can store in a blob else???
              if(b.length <= 1000000){
                propValue = new Blob(b);
              }else{
                throw new SienaException("object can be java serialized because it's too large >1mb");
              }               
            }
            catch(IOException ex) {
View Full Code Here

    }
    else
    {
      try
      {
        Blob blob = (Blob) entityValue;
        ByteArrayInputStream bais = new ByteArrayInputStream(blob.getBytes());
        ObjectInputStream ois = new ObjectInputStream(bais);
        return ois.readObject();
      }
      catch (Exception e)
      {
View Full Code Here

      {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(256);
        ObjectOutputStream stream = new ObjectOutputStream(baos);
        stream.writeObject(objectValue);
        stream.close();
        return new Blob(baos.toByteArray());
      }
      catch (Exception e)
      {
        throw new IllegalStateException(e);
      }
View Full Code Here

  }

  @Override
  protected Object encode(Object objectValue)
  {
    return new Blob((byte[]) objectValue);
  }
View Full Code Here

  public Noticia(byte[] bs) {
    super();
    ImagesService service = ImagesServiceFactory.getImagesService();
    Transform transform = ImagesServiceFactory.makeImFeelingLucky();
    Image image = service.applyTransform(transform, ImagesServiceFactory.makeImage(bs));
    this.arquivo = new Blob(image.getImageData());
    this.dataCadastro = new Date();
  }
View Full Code Here

            memcache.put(id, bytes, expires);

            DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
            Entity entity = new Entity(AC_BASE, id);
            entity.setProperty(PROPERTY_EXPIRES, expire.getTime());
            entity.setProperty(PROPERTY_DATA, new Blob(bytes));
            ds.put(entity);

        } catch (DeadlineExceededException e) {
            log.severe("DeadlineExceeded for " + session.getId());
            sendDeadlineExceededNotification(request, response);
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.Blob

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.