Package evolaris.framework.blog.business

Examples of evolaris.framework.blog.business.FCKEditorManager


  Session session;
 
  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

      return;
    }
    session = HibernateSessions.startTransaction(this.getClass());
    try {
      LOGGER.debug("--- BEGIN DOGET ---");
      FCKEditorManager fckMgr = new FCKEditorManager(Locale.GERMAN, session);
     
      response.setContentType("text/xml; charset=UTF-8");
      response.setHeader("Cache-Control","no-cache");
      PrintWriter out = response.getWriter();
     
      String commandStr=request.getParameter("Command");
      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

      return;
    }   
    session = HibernateSessions.startTransaction(this.getClass());
    try {
      if (debug) System.out.println("--- BEGIN DOPOST ---");
      FCKEditorManager fckMgr = new FCKEditorManager(Locale.GERMAN, session);     
 
      response.setContentType("text/html; charset=UTF-8");
      response.setHeader("Cache-Control","no-cache");
      PrintWriter out = response.getWriter();
     
      String commandStr=request.getParameter("Command");
      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";
      String fileName="";
     
      if(!commandStr.equals("FileUpload"))
        retVal="203";
      else {
        ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
        try {
          List items = upload.parseRequest(request);
         
          Map fields=new HashMap();
         
          Iterator iter = items.iterator();
          while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();
            if (item.isFormField()) {
              fields.put(item.getFieldName(),item.getString());
            } else {
              fields.put(item.getFieldName(),item);
            }
          }
          FileItem uplFile=(FileItem)fields.get("NewFile");
          String fileNameLong=uplFile.getName();
          fileNameLong=fileNameLong.replace('\\','/');
          fileNameLong=fileNameLong.replaceAll("[^a-zA-Z_0-9/:.]", "_");
          String[] pathParts=fileNameLong.split("/");
          fileName=pathParts[pathParts.length-1];
         
          String nameWithoutExt=getNameWithoutExtension(fileName);
          String ext=getExtension(fileName);
          int counter=1;
          while(fckMgr.getFile(blogCode, currentDir, fileName, false) != null) {
            fileName = nameWithoutExt+"("+counter+")"+"."+ext;
            retVal="201";
            counter++;
          }
          byte[] fileData = uplFile.get();
          if (fileData != null && fileData.length > 0) {  // this also happens if the file does not exist => no precise error message possible
            fckMgr.saveFile(blogCode, currentDir, fileName, fileData, uplFile.getContentType(), user);
          }         
        } catch (Exception ex) {
          retVal="203";
        }
       
View Full Code Here

    String contentType = null;
   
    Session session = HibernateSessions.startTransaction(this.getClass());
    String filepath = "";
    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) {
View Full Code Here

    if (blogCode == null) {
      return;
    }
    session = HibernateSessions.startTransaction(this.getClass());
    try {
      FCKEditorManager fckMgr = new FCKEditorManager(Locale.GERMAN, session);
     
    response.setContentType("text/html; charset=UTF-8");
    response.setHeader("Cache-Control","no-cache");
    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";
    String fileUrl="";
    String fileName="";
    String errorMessage="";
   
    if(enabled) {   
      ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
      try {
        List items = upload.parseRequest(request);
       
        Map fields=new HashMap();
       
        Iterator iter = items.iterator();
        while (iter.hasNext()) {
          FileItem item = (FileItem) iter.next();
          if (item.isFormField())
            fields.put(item.getFieldName(),item.getString());
          else
            fields.put(item.getFieldName(),item);
        }
        FileItem uplFile=(FileItem)fields.get("NewFile");
        String fileNameLong=uplFile.getName();
        fileNameLong=fileNameLong.replace('\\','/');
        fileNameLong=fileNameLong.replaceAll("[^a-zA-Z_0-9/:.]", "_");
        String[] pathParts=fileNameLong.split("/");
        fileName=pathParts[pathParts.length-1];
       
        String nameWithoutExt=getNameWithoutExtension(fileName);
        String ext=getExtension(fileName);
        if(extIsAllowed(typeStr,ext)) {
          int counter=1;
          while(fckMgr.getFile(blogCode, currentDir, fileName, false) != null) {
            fileName = nameWithoutExt+"("+counter+")"+"."+ext;
            retVal="201";
            counter++;
          }
          byte[] fileData = uplFile.get();
          if (fileData != null && fileData.length > 0) {  // this also happens if the file does not exist => no precise error message possible
            fckMgr.saveFile(blogCode, currentDir, fileName, fileData, uplFile.getContentType(), user);
          }                   
        } else {
          retVal="202";
          errorMessage="";
          LOGGER.debug("Invalid file type: " + ext)
View Full Code Here

TOP

Related Classes of evolaris.framework.blog.business.FCKEditorManager

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.