Package org.yaac.shared.file

Examples of org.yaac.shared.file.CacheUploadResult


          byte[] rawData = FileUtil.toByteArray(stream)// cache data

          memcache.put(randomId, rawData);
          logger.info("Cached uploaded file id : " + randomId + " with size = " + rawData.length);
         
          CacheUploadResult result = AutoBeanUtil.newCacheUploadResult(Status.SUCCESS, randomId, item.getName(), rawData.length);
          resultStr = AutoBeanUtil.encode(CacheUploadResult.class, result);
        } finally {
          stream.close();
        }
      }
    } catch (FileUploadException e) {
      CacheUploadResult result = AutoBeanUtil.newCacheUploadResult(Status.FAIL, null, null, null);
      resultStr = AutoBeanUtil.encode(CacheUploadResult.class, result);
     
      logger.log(Level.SEVERE, "failed to upload file", e);
    }
   
View Full Code Here


   * @param size
   * @return
   */
  public static CacheUploadResult newCacheUploadResult(CacheUploadResult.Status status,
      String cacheKey, String fileName, Integer size) {
    CacheUploadResult result = abf.cacheUploadResult().as();
    result.setStatus(status);
    result.setPath(newFileDownloadPath(Type.MEMCACHE, cacheKey, null, null, fileName, size));
    return result;
  }
View Full Code Here

  void onFormSubmitComplete(SubmitCompleteEvent event) {   
    BlockingAsyncCallback.unblock();
   
    // if event.getResults returns null, then the form is not even submitted
    if (!isNullOrEmpty(event.getResults())) {  // print out result
      CacheUploadResult result = AutoBeanUtil.decode(CacheUploadResult.class, event.getResults());
     
      if (result.getStatus() == Status.SUCCESS) {
        this.dataProvider.getList().add(result.getPath());
        this.dataProvider.refresh();
        this.form.reset();
      } else // upload failed
        Window.alert("Can't upload file")// TODO : i18n
      }
View Full Code Here

TOP

Related Classes of org.yaac.shared.file.CacheUploadResult

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.