Package com.baasbox.dao

Examples of com.baasbox.dao.FileDao


      return doc;
    }
    public static ODocument createFile(String fileName, String data,
        String contentType, long contentLength, InputStream is,
        HashMap<String,?> metadata, String contentString) throws Throwable {
      FileDao dao = FileDao.getInstance();
      ODocument doc=dao.create(fileName,contentType,contentLength,is,metadata,contentString);
      if (data!=null && !data.trim().isEmpty()) {
        ODocument metaDoc=(new ODocument()).fromJSON("{ '"+DATA_FIELD_NAME+"' : " + data + "}");
        doc.merge(metaDoc, true, false);
      }
      dao.save(doc);
      return doc;
    }
View Full Code Here


      return doc;
    }//createFile with permission
   
   
    public static ODocument createFile(String fileName,String data,String contentType, long contentLength , InputStream content) throws Throwable{
      FileDao dao = FileDao.getInstance();
      ODocument doc=dao.create(fileName,contentType,contentLength,content);  
      if (data!=null && !data.trim().isEmpty()) {
        ODocument metaDoc=(new ODocument()).fromJSON("{ '"+DATA_FIELD_NAME+"' : " + data + "}");
        doc.merge(metaDoc, true, false);
      }
      dao.save(doc);
      return doc;
   
View Full Code Here

      dao.save(doc);
      return doc;
   
   
    public static ODocument createFile(String fileName,String data,String contentType, HashMap<String,?> metadata,long contentLength , InputStream content) throws Throwable{
      FileDao dao = FileDao.getInstance();
      ODocument doc=dao.create(fileName,contentType,contentLength,content);
      if (data!=null && !data.trim().isEmpty()) {
        ODocument metaDoc=(new ODocument()).fromJSON("{ '"+DATA_FIELD_NAME+"' : " + data + "}");
        doc.merge(metaDoc, true, false);
      }
      dao.save(doc);
      return doc;
    }
View Full Code Here

      dao.save(doc);
      return doc;
    }
   
    public static ODocument getById(String id) throws SqlInjectionException, InvalidModelException {
      FileDao dao = FileDao.getInstance();
      return dao.getById(id);
    }
View Full Code Here

      FileDao dao = FileDao.getInstance();
      return dao.getById(id);
    }
   
    public static void deleteById(String id) throws Throwable, SqlInjectionException, FileNotFoundException{
      FileDao dao = FileDao.getInstance();
      ODocument file=getById(id);
      if (file==null) throw new FileNotFoundException();
      dao.delete(file.getIdentity());
    }
View Full Code Here

      dao.delete(file.getIdentity());
    }


    public static List<ODocument> getFiles(QueryParams criteria) throws SqlInjectionException {
      FileDao dao = FileDao.getInstance();
      return dao.get(criteria);
    }
View Full Code Here

      if (!StorageUtils.docIsAnImage(file)) throw new DocumentIsNotAnImageException("The file " + id + " is not an image");
      //are the dimensions allowed?
      //the check is delegated to the caller
      String sizePattern= dimensions.toString();
      try{
        FileDao dao=FileDao.getInstance();
        byte[] resizedImage = dao.getStoredResizedPicture( file,  sizePattern);
        if (resizedImage!=null) return resizedImage;
       
        ByteArrayOutputStream fileContent = StorageUtils.extractFileFromDoc(file);
        if (fileContent.toByteArray().length==0) return new byte[]{};
        String contentType = getContentType(file);
        String ext = contentType.substring(contentType.indexOf("/")+1);
        WritebleImageFormat format;
        try{
          format = WritebleImageFormat.valueOf(ext);
        }catch (Exception e){
          format= WritebleImageFormat.png;
        }
        resizedImage=StorageUtils.resizeImage(fileContent.toByteArray(), format, dimensions);
       
        //save the resized image for future requests
        dao.storeResizedPicture(file, sizePattern, resizedImage);
        return resizedImage;
      }catch ( InvalidModelException e) {
        throw new RuntimeException("A very strange error occurred! ",e);
      }catch (OutOfMemoryError e){
        throw new FileTooBigException();
View Full Code Here

    }
   
    public static String getExtractedContent(String id) throws SqlInjectionException, InvalidModelException, FileNotFoundException {
      ODocument file = getById(id);
      if (file==null) throw new  FileNotFoundException();
      FileDao dao = FileDao.getInstance();
      String ret=dao.getExtractedContent(file);
      return ret;
    }
View Full Code Here

    public static ImmutableMap data() throws SqlInjectionException, InvalidCollectionException{
      if (Logger.isTraceEnabled()) Logger.trace("Method Start");
      UserDao userDao = UserDao.getInstance();
      CollectionDao collDao = CollectionDao.getInstance();
      AssetDao assetDao = AssetDao.getInstance();
      FileDao fileDao = FileDao.getInstance();
      ODatabaseRecordTx db = DbHelper.getConnection();
     
      long usersCount =userDao.getCount();
      long assetsCount = assetDao.getCount();
      long collectionsCount = collDao.getCount();
      long filesCount = fileDao.getCount();
     
      List<ODocument> collections = collDao.get(QueryParams.getInstance());
      ArrayList<ImmutableMap> collMap = collectionsDetails(collections);
      ImmutableMap response = ImmutableMap.of(
          "users", usersCount,
View Full Code Here

TOP

Related Classes of com.baasbox.dao.FileDao

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.