Package com.orientechnologies.orient.core.record.impl

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes


      return binary.toStream();
  }

  public ODocument setBinary(ODocument doc, byte[] content) throws InvalidModelException {
    super.checkModelDocument(doc);
    ORecordBytes record = new ORecordBytes(content);
    doc.field(BINARY_FIELD_NAME,record);
    doc.field("contentLength",content.length);
    return doc;
  }
View Full Code Here


 
  public  byte[] getStoredResizedPicture(ODocument asset, String sizePattern) throws InvalidModelException{
    super.checkModelDocument(asset);
    Map<String,ORID> resizedMap=(Map<String,ORID>) asset.field("resized");
    if (resizedMap!=null && resizedMap.containsKey(sizePattern)){
      ORecordBytes obytes = (ORecordBytes) resizedMap.get(sizePattern);
      return obytes.toStream();
    }
    return null;
  }
View Full Code Here

 
  public  void storeResizedPicture(ODocument asset,String sizePattern, byte[] resizedImage) throws InvalidModelException {
    super.checkModelDocument(asset);
    Map<String,ORID> resizedMap=(Map<String,ORID>) asset.field("resized");
    if (resizedMap==null) resizedMap=new HashMap<String,ORID>();
    resizedMap.put(sizePattern, new ORecordBytes().fromStream(resizedImage).save().getIdentity());
    asset.field("resized",resizedMap);
    this.save(asset);
  }
View Full Code Here

    throw new IllegalAccessError("Use create(String name, String fileName, String contentType, byte[] content) instead");
  }
 
  public ODocument create(String fileName, String contentType, byte[] content) throws Throwable{
    ODocument file=super.create();
    ORecordBytes record = new ORecordBytes(content);
    file.field(BINARY_FIELD_NAME,record);
    file.field(FILENAME_FIELD_NAME,fileName);
    file.field(CONTENT_TYPE_FIELD_NAME,contentType);
    file.field(CONTENT_LENGTH_FIELD_NAME,new Long(content.length));
    return file;
View Full Code Here

 
  public ODocument create(String fileName, String contentType,
      long contentLength, InputStream is, HashMap<String, ?> metadata,
      String contentString) throws Throwable {
    ODocument file=super.create();
    ORecordBytes record = new ORecordBytes();
    record.fromInputStream(is, (int) contentLength);
    file.field(BINARY_FIELD_NAME,record);
    file.field(FILENAME_FIELD_NAME,fileName);
    file.field(CONTENT_TYPE_FIELD_NAME,contentType);
    file.field(CONTENT_LENGTH_FIELD_NAME,new Long(contentLength));
    if (metadata!=null){
View Full Code Here

 
  public  byte[] getStoredResizedPicture(ODocument file, String sizePattern) throws InvalidModelException{
    super.checkModelDocument(file);
    Map<String,ORID> resizedMap=(Map<String,ORID>) file.field(RESIZED_IMAGE_FIELD_NAME);
    if (resizedMap!=null && resizedMap.containsKey(sizePattern)){
      ORecordBytes obytes = (ORecordBytes) resizedMap.get(sizePattern);
      return obytes.toStream();
    }
    return null;
  }
View Full Code Here

 
  public  void storeResizedPicture(ODocument file,String sizePattern, byte[] resizedImage) throws InvalidModelException {
    super.checkModelDocument(file);
    Map<String,ORID> resizedMap=(Map<String,ORID>) file.field(RESIZED_IMAGE_FIELD_NAME);
    if (resizedMap==null) resizedMap=new HashMap<String,ORID>();
    resizedMap.put(sizePattern, new ORecordBytes().fromStream(resizedImage).save().getIdentity());
    file.field(RESIZED_IMAGE_FIELD_NAME,resizedMap);
    try{
      this.save(file);
    }catch (OConcurrentModificationException e){
      //just ignore it...
View Full Code Here

 
  public static ByteArrayOutputStream getFileAsStream (String fileAssetName) throws SqlInjectionException, IOException{
    FileAssetDao dao = FileAssetDao.getInstance();
    ODocument fileAsset=dao.getByName(fileAssetName);
    if (fileAsset==null) return null;
    ORecordBytes record = fileAsset.field("file");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    record.toOutputStream(out);
    return out;
  }
View Full Code Here

  @With ({AnonymousCredentialWrapFilter.class, ConnectToDBFilter.class})
  public static Result download(String name,boolean forceDownload) throws InvalidModelException, IOException {
    try {
      ODocument doc=AssetService.getByName(name);
      if (doc==null || doc.field("file")==null) return notFound();
      ORecordBytes record = doc.field("file");
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      record.toOutputStream(out);
      response().setContentType(AssetService.getContentType(doc));
      if(forceDownload) response().setHeader("Content-Disposition", "attachment; filename=\""+URLEncoder.encode((String)doc.field("fileName"),"UTF-8")+"\"");
      response().setHeader("Content-Length", ((Long)doc.field("contentLength")).toString());
      //return ok(new ByteArrayInputStream(out.toByteArray()));
      return ok(out.toByteArray());
View Full Code Here

    try {

      final OBinarySerializer keySerializer = determineKeySerializer(indexDefinition);
      final int keySize = determineKeySize(indexDefinition);

      final ORecordBytes identityRecord = new ORecordBytes();
      ODatabaseRecordInternal database = getDatabase();

      final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying();

      database.save(identityRecord, clusterIndexName);
      identity = identityRecord.getIdentity();

      sbTree.create(indexName, keySerializer, (OBinarySerializer<V>) valueSerializer,
          indexDefinition != null ? indexDefinition.getTypes() : null, storageLocalAbstract, keySize, indexDefinition != null
              && !indexDefinition.isNullValuesIgnored());
    } finally {
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.record.impl.ORecordBytes

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.