Package org.yaac.shared.property

Examples of org.yaac.shared.property.BlobPropertyInfo


      Blob b = (Blob) obj;
      String fileName = index == null ? propertyName : propertyName + "[" + index + "]";
      FileDownloadPath downloadPath = AutoBeanUtil.newFileDownloadPath(
          FileDownloadPath.Type.DATASTORE_BLOB, keyString, propertyName, index, fileName, b.getBytes().length);
      String pathStr = AutoBeanUtil.encode(FileDownloadPath.class, downloadPath);
      result = new BlobPropertyInfo(b.getBytes().length, pathStr);
    } else if (obj instanceof BlobStringWrapper) {  // user has edited a blob, in string form, it's not in memcache, nor datastore
      result = new BlobPropertyInfo(((BlobStringWrapper) obj).getRawString().getBytes());
    } else if (obj instanceof BlobFileRefWrapper) {  // user has uploaded the blob, but still stay in memcache
      FileDownloadPath path = ((BlobFileRefWrapper) obj).getRef();
      String pathStr = AutoBeanUtil.encode(FileDownloadPath.class, path);
      result = new BlobPropertyInfo(path.getSize(), pathStr);
    } else if (obj instanceof BlobKey) {
      String blobKeyString = ((BlobKey) obj).getKeyString();
      result = new BlobKeyPropertyInfo(blobKeyString);
    } else if (obj instanceof Key) {
      result = convert((Key)obj);
View Full Code Here


  private Object convert(PropertyInfo info, Entity e) {
    PropertyType type = PropertyType.typeOf(info);
   
    switch (type) {
    case BLOB:
      BlobPropertyInfo blobInfo = (BlobPropertyInfo) info;
     
      if (blobInfo.getRawData() == null) {
        FileDownloadPath path = AutoBeanUtil.decode(FileDownloadPath.class, blobInfo.getDownloadPath());

        switch (path.getType()) {
        case MEMCACHE:
          byte [] data = (byte[]) memcache.get(path.getKeyStr());
          // throw exception when rawData == null? cache get expired is possible
          return new Blob(data);
        case DATASTORE_BLOB:
          // simply return existing one
          Object val = e.getProperty(path.getFieldName());
          if (val instanceof Blob) {
            return val;
          } else if (val instanceof List) {
            return ((List)val).get(path.getIndex());
          } else {
            // should not happen
            throw new IllegalArgumentException("Can't locate blob via path " + path.getFieldName() + " " + path.getIndex());
          }
        default:
          // should not happen
          throw new IllegalArgumentException("Can't locate blob via path " + path.getFieldName() + " " + path.getIndex());
        }
      } else {
        // edit blob value directly
        return new Blob(blobInfo.getRawData());
      }
    case BLOB_KEY:
      return new BlobKey(((BlobKeyPropertyInfo) info).getBlobKey());
    case BOOL:
      return ((BooleanPropertyInfo) info).getPayload();
View Full Code Here

TOP

Related Classes of org.yaac.shared.property.BlobPropertyInfo

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.