Package com.baasbox.exception

Examples of com.baasbox.exception.DocumentIsNotAFileException


      //get the file
      ODocument file;
      try {
        file = getById(id);
      } catch (InvalidModelException e1) {
        throw new DocumentIsNotAFileException("The id " + id + " is not a file");
      }
      if (file==null) throw new DocumentNotFoundException();
      //is the file an image?
      if (!StorageUtils.docIsAnImage(file)) throw new DocumentIsNotAnImageException("The file " + id + " is not an image");
      //are the dimensions allowed?
View Full Code Here


    throw new InvalidSizePatternException(sizePattern + " is not valid: missing the '-' character between the width and the height");
  }


  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

TOP

Related Classes of com.baasbox.exception.DocumentIsNotAFileException

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.