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

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


        final ORecordStringable record = (ORecordStringable) iRecord;
        json.writeAttribute(settings.indentLevel + 1, true, "value", record.value());

      } else if (iRecord instanceof ORecordBytes) {
        // BYTES
        final ORecordBytes record = (ORecordBytes) iRecord;
        json.writeAttribute(settings.indentLevel + 1, true, "value", OBase64Utils.encodeBytes(record.toStream()));
      } else

        throw new OSerializationException("Error on marshalling record of type '" + iRecord.getClass()
            + "' to JSON. The record type cannot be exported to JSON");
View Full Code Here


public class ORecordSerializerRaw implements ORecordSerializer {
  public static final String NAME = "ORecordDocumentRaw";

  public ORecord fromStream(final byte[] iSource) {
    return new ORecordBytes(iSource);
  }
View Full Code Here

  public String toString() {
    return NAME;
  }

  public ORecord fromStream(final byte[] iSource, final ORecord iRecord, String[] iFields) {
    final ORecordBytes record = (ORecordBytes) iRecord;
    record.fromStream(iSource);
    record.reset(iSource);

    return record;
  }
View Full Code Here

    Assert.assertEquals(new String((byte[]) doc.field("binary", OType.BINARY)), "Binary data");
  }

  @Test
  public void testBasicCreateExternal() {
    ORecordBytes record = new ORecordBytes(database, "This is a test".getBytes());
    record.save();
    rid = record.getIdentity();
  }
View Full Code Here

    rid = record.getIdentity();
  }

  @Test(dependsOnMethods = "testBasicCreateExternal")
  public void testBasicReadExternal() {
    ORecordBytes record = database.load(rid);

    Assert.assertEquals("This is a test", new String(record.toStream()));
  }
View Full Code Here

  }

  @Test(dependsOnMethods = "testBasicReadExternal")
  public void testMixedCreateExternal() {
    ODocument doc = new ODocument();
    doc.field("binary", new ORecordBytes(database, "Binary data".getBytes()));

    doc.save();
    rid = doc.getIdentity();
  }
View Full Code Here


  public static ByteArrayOutputStream extractFileFromDoc(ODocument doc) throws DocumentIsNotAFileException, IOException{
    if (!docIsAFile(doc)) throw new DocumentIsNotAFileException();
    if (!doc.containsField("file")) throw new DocumentIsNotAFileException("the file field does not exist");
    ORecordBytes record = null;
    try {
      record = doc.field("file");
    }catch (Exception e){
      throw new DocumentIsNotAFileException("The file field exists but does not contains a valid file");
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    record.toOutputStream(out);
    return out;
  }
View Full Code Here

          ImageDimensions imgDim = StorageUtils.convertPatternToDimensions(resize);
          output = FileService.getResizedPicture(id, imgDim);
          String[] fileName=((String)doc.field("fileName")).split("\\.");
          filename=fileName[0] + "_" + resize + "." + (fileName.length>1?fileName[1]:"");
        }else{
          ORecordBytes record = doc.field(FileService.BINARY_FIELD_NAME);
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          record.toOutputStream(out);
          output=out.toByteArray();
        }
        response().setContentType((String)doc.field(FileService.CONTENT_TYPE_FIELD_NAME));
        response().setHeader("Content-Length", String.valueOf(output.length));
        if (download) response().setHeader("Content-Disposition", "attachment; filename=\""+URLEncoder.encode(filename,"UTF-8")+"\"");
View Full Code Here

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

    return doc.field(BINARY_FIELD_NAME);
  }
 
  public byte[] getBinaryAsByte(ODocument doc) throws InvalidModelException{
      super.checkModelDocument(doc);
      ORecordBytes binary=doc.field(BINARY_FIELD_NAME);
      return binary.toStream();
  }
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.