EditFileEntryAction.java

protected FileEntry updateFileEntry(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
/* 此处强转获取uploadPortletRequest,用于获取InputStream,也可以使用如下代码:
* HttpServletRequest request = serviceContext.getRequest();
* UploadRequest uploadRequest = PortalUtil.getUploadServletRequest(request);
* inputStream = uploadRequest.getFileAsStream(fieldName);
*/
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); ... // 获取folderId, 如果自己创建的话,要走DLFolderLocalServiceUtil.java
if (folderId > 0) {
Folder folder = DLAppServiceUtil.getFolder(folderId); if (folder.getGroupId() != themeDisplay.getScopeGroupId()) {
throw new NoSuchFolderException("{folderId=" + folderId + "}");
}
} InputStream inputStream = null; try {
String contentType = uploadPortletRequest.getContentType("file"); // inputStream.available()用于获取size
long size = uploadPortletRequest.getSize("file"); ... // 获取inputStream
inputStream = uploadPortletRequest.getFileAsStream("file"); ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(), uploadPortletRequest); FileEntry fileEntry = null; // Add file entry fileEntry = DLAppServiceUtil.addFileEntry(
repositoryId, folderId, sourceFileName, contentType, title,
description, changeLog, inputStream, size, serviceContext); // Update file entry and checkin fileEntry = DLAppServiceUtil.updateFileEntryAndCheckIn(
fileEntryId, sourceFileName, contentType, title,
description, changeLog, majorVersion, inputStream, size,
serviceContext);
}

DLAppServiceUtil.java

public FileEntry addFileEntry(long repositoryId, long folderId, String sourceFileName, String mimeType, String title,
String description, String changeLog, InputStream is, long size, ServiceContext serviceContext)
throws PortalException, SystemException { ... File file = null; try {
/* 创建tempFile,inputStream读取的文件放在tomcat-7.0.62/temp/xxxfile
* 根据inputStream创建一个tempFile,然后存储对应的关系到数据库,文件根据数据库中的路径存放在bundle/data/document_library下
*/
file = FileUtil.createTempFile(is); return addFileEntry(repositoryId, folderId, sourceFileName, mimeType, title,
description, changeLog, file, serviceContext);
} catch (IOException ioe) {
throw new SystemException("Unable to write temporary file", ioe);
} finally {
// 不论addFile是否成功都会删除临时文件
FileUtil.delete(file);
}
}
}
...
}

文件路径在数据库中的dlfileentry中存储,与bundle/data/document_library的对应关系如下:

Table Column companyid folderid treepath name
Path document_library/ companyid folderid /folderid/

存储的文件名会有1。0,2.0之类的,标记的是文件的版本,具体在dlfileversion这张表中

...待续

[Java][Liferay] File system in liferay的更多相关文章

  1. java hadoop file system API

    org.apache.hadoop.fs Class FileSystem java.lang.Object org.apache.hadoop.fs.FileSystem All Implement ...

  2. java.nio.file.Path

    public interface Path extends Comparable<Path>, Iterable<Path>, Watchable 1. A Path repr ...

  3. Java篇-File类之常用操作

    /** * */ package com.io.file; import java.io.File; import java.io.IOException; /** * <pre> * & ...

  4. Java篇-File类之创建删除

    /** * */ package com.io.file; import java.io.File; import java.io.IOException; import org.junit.Test ...

  5. IO:File类(java.io.File)

    public class File extends Object implements Serializable, Comparable<File> 构造方法: public File(S ...

  6. Java class file format specfication

    Java class file format spec Link: https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html Her ...

  7. java.io.file

    package cn.edu.tongji.cims.wade.system;     import java.io.*;     public class FileOperate {     pub ...

  8. java获取指定路径下的指定文件/java.io.File.listFiles(FilenameFilter filter)

    java.io.File.listFiles(FilenameFilter filter) 返回抽象路径名数组,表示在目录中此抽象路径名表示,满足指定过滤器的文件和目录. 声明 以下是java.io. ...

  9. 【java IO File】统计项目代码总共多少行

    统计项目代码总共有多少行 思想: 1.首先将不需要迭代的文件夹,保存在集合中,不满足的就是需要迭代的文件夹 2.将需要进行统计行数的代码文件保存在集合中,满足的就是需要计算文件行数的文件 3.迭代方法 ...

随机推荐

  1. 写一个Android输入法01——最简步骤

    本文演示用Android Studio写一个最简单的输入法.界面和交互都很简陋,只为剔肉留骨,彰显写一个Android输入法的要点. 1.打开Android Studio创建项目,该项目和普通APP的 ...

  2. JavaFx 实现画图工具

    制作一款类似于Windows画图工具程序 功能需求: (1)在画布上绘制直线.曲线.矩形.椭圆等图形 (2)实现输入文字,橡皮擦 (3)可以绘制填充图形以及设置画笔的颜色和粗细 (4)实现撤销操作.保 ...

  3. HSF的原理分析

    转自:http://blog.csdn.net/qq_16681169/article/details/72512819 一.HSF的基本概念 HSF全称为High-Speed Service Fra ...

  4. Python列表知识补充

    1.import this  Python之禅,圣经. >>> import this The Zen of Python, by Tim Peters Beautiful is b ...

  5. Apache 性能调优-参考篇

    1 内存     适当选用适合大小的内存,保证谷峰负载时,有足够的内存使用 2 使用ab测试apache性能 ab -n 1000 -c 10 http://www.test.com 使用ab的缺点: ...

  6. LB 负载均衡的层次结构(转)

    http://blog.csdn.net/mindfloating/article/details/51020767 作为后端应用的开发者,我们经常开发.调试.测试完我们的应用并发布到生产环境,用户就 ...

  7. CSS之引入样式

    CSS引入样式 内部样式 内嵌式是将CSS代码集中写在HTML文档的head头部标签中,并且用style标签定义,其基本语法格式如下: <head> <style type=&quo ...

  8. 解决三星官方移植的内核默认是没有打开支持V4L USB devices

         在linux比较新的kernel,都标配了各类摄像头的驱动支持,不用我们自己移植驱动,只需通过make menuconfig配置内核支持我们所需的摄像头类型即可.以下是在三星官方内核中配置V ...

  9. 16.Shortest Unsorted Continuous Subarray(最短未排序子数组)

    Level:   Easy 题目描述: Given an integer array, you need to find one continuous subarray that if you onl ...

  10. HDU6298 Maximum Multiple (多校第一场1001)

    Maximum Multiple Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...