Package evolaris.framework.blog.datamodel

Examples of evolaris.framework.blog.datamodel.File


 
  public void testCreateFolder() {
    session = HibernateSessions.startTransaction(this.getClass());
    try {
      FCKEditorManager fckMgr = new FCKEditorManager(Locale.GERMAN, session);
      File f = fckMgr.createFolder("tstblg1", "/foo/bar/images/", null);
      assertEquals("images", f.getFilename());
    } catch (Exception e) {
      HibernateSessions.rollbackTransaction(session,this.getClass());
    } finally {
      HibernateSessions.finishTransaction(session,this.getClass());
    }
View Full Code Here


 
  public void testGetFolder() {
    session = HibernateSessions.startTransaction(this.getClass());
    try {
      FCKEditorManager fckMgr = new FCKEditorManager(Locale.GERMAN, session);
      File f = fckMgr.getFolder("tstblg1", "/foo/bar/images/");
      assertEquals("images", f.getFilename());
    } catch (Exception e) {
      HibernateSessions.rollbackTransaction(session,this.getClass());
    } finally {
      HibernateSessions.finishTransaction(session,this.getClass());
    }
View Full Code Here

      String typeStr=request.getParameter("Type");
      String currentFolderStr=request.getParameter("CurrentFolder");
     
      String currentPath=baseDir+typeStr+currentFolderStr;
     
      File currentDir = fckMgr.getFolder(blogCode, currentPath);
      if (currentDir == null) {
        currentDir = fckMgr.createFolder(blogCode, currentPath, user);
      }
     
      Document document=null;
      try {
        DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        document=builder.newDocument();
      } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
      }
     
      Node root=CreateCommonXml(document,commandStr,typeStr,currentFolderStr,"some.fckcontent?blog="+blogCode+"&filepath="+currentPath);
     
      LOGGER.debug("Command = " + commandStr);
     
      if(commandStr.equals("GetFolders")) {
        getFolders(currentDir,root,document);
      }
      else if (commandStr.equals("GetFoldersAndFiles")) {
        getFolders(currentDir,root,document);
        getFiles(currentDir,root,document);
      }
      else if (commandStr.equals("CreateFolder")) {
        String newFolderStr=request.getParameter("NewFolderName");
        String retValue="110";
       
        if(fckMgr.getFolder(blogCode, currentPath+newFolderStr) != null) {
          retValue="101";
        }
        else {
          File newFolder=fckMgr.createFolder(blogCode, currentPath+newFolderStr, user);
          if (newFolder != null) {
            retValue="0";
          } else {
            retValue="102";
          }       
View Full Code Here

      String typeStr=request.getParameter("Type");
      String currentFolderStr=request.getParameter("CurrentFolder");
     
      String currentPath=baseDir+typeStr+currentFolderStr;
     
      File currentDir = fckMgr.getFolder(blogCode, currentPath);
      if (currentDir == null) {
        currentDir = fckMgr.createFolder(blogCode, currentPath, user);
      }
     
      String retVal="0";
View Full Code Here

    try {
      FCKEditorManager fckMgr = new FCKEditorManager(Locale.GERMAN, session);
      String blogCode = (String)request.getParameter("blog");
      filepath = (String)request.getParameter("filepath");
      LOGGER.debug("before getting file " + filepath);
      File file = fckMgr.getFile(blogCode, filepath);
     
      if (file != null) { 
        contentType = file.getContentType();
        Blob blob = file.getData();
        if(blob != null && blob.length() > 0) {
          bytes = blob.getBytes(1l, new Long(blob.length()).intValue());
        } else {
          LOGGER.error("Providing content failed! No data in file `"+filepath+"' of blog `"+blogCode+"`");
          response.sendError(HttpServletResponse.SC_NOT_FOUND);       
View Full Code Here

    this.session = session;   
  }
 
  public void saveFile(String blogCode, File currentDir, String fileName, byte[] fileData, String contentType, User user) {
    Blob dataBlob = Hibernate.createBlob(fileData);
    File f = new File();
    f.setData(dataBlob);
    f.setFilename(fileName);
    f.setContentType(contentType);
    f.setBlogCode(blogCode);
    f.setParent(currentDir);
    f.setUser(user);
    f.setCreatedAt(new Date());     
    currentDir.getChildren().add(f);
    session.saveOrUpdate(currentDir)// cascade saves f too
 
View Full Code Here

    session.saveOrUpdate(currentDir)// cascade saves f too
 

  public File getFolder(String blogCode, String currentDirPath) {
    String[] parts = currentDirPath.split("/");
    File file = null;
    for (String s : parts) {
      file = getFile(blogCode, file, s, true);
      if (file == null) {
        return null;
      }
View Full Code Here

    return file;
  }
   
  public File getFile(String blogCode, String currentDirPath) {
    String[] parts = currentDirPath.split("/");
    File file = null;
    for (String s : parts) {
      file = getFile(blogCode, file, s, false);
      if (file == null) {
        return null;
      }
View Full Code Here

    return file;
  }
 
  public File createFolder(String blogCode, String currentDirPath, User user) {
    String[] parts = currentDirPath.split("/");
    File file = null;
    for (String s : parts) {
      File next = getFile(blogCode, file, s, true);
      if (next == null) {
        next = new File();
        next.setBlogCode(blogCode);
        next.setContentType("folder");
        next.setFilename(s);
        next.setParent(file);
        next.setUser(user);
        next.setCreatedAt(new Date());
        session.saveOrUpdate(next);
        if (file != null) {
          file.getChildren().add(next);
          session.saveOrUpdate(file);
        }
View Full Code Here

    PrintWriter out = response.getWriter();
   
    String typeStr=request.getParameter("Type");
    String currentPath=baseDir+typeStr;
   
    File currentDir = fckMgr.getFolder(blogCode, currentPath);
    if (currentDir == null) {
      currentDir = fckMgr.createFolder(blogCode, currentPath, user);
    }
       
    String retVal="0";
View Full Code Here

TOP

Related Classes of evolaris.framework.blog.datamodel.File

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.