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. jquery - min.js /jquery-1.8.3.min.js引入后报错

    解决方法:在“jquery-1.8.3.min.js”文件上,点击鼠标右键,在弹出菜单中选择“myeclipse”->"exclude From Validation",错误 ...

  2. day01.2-计算机网络协议

    注:本文摘自林海峰老师的博客,作为个人学习笔记,日后方便阅读,原文详见链接www.cnblogs.com/linhaifeng/articles/5937962.html 一.  ISO协议     ...

  3. Python中logging模块的基本用法

    在 PyCon 2018 上,Mario Corchero 介绍了在开发过程中如何更方便轻松地记录日志的流程. 整个演讲的内容包括: 为什么日志记录非常重要 日志记录的流程是怎样的 怎样来进行日志记录 ...

  4. codevs1068(dp)

    题目链接: http://codevs.cn/problem/1068/ 题意: 中文题诶~ 思路: dp 用 dp[i][j][k][l] 表示取 i 个 1, j 个 2, k 个 3, l 个 ...

  5. LCA 【bzoj 4281】 [ONTAK2015]Związek Harcerstwa Bajtockiego

    [bzoj 4281] [ONTAK2015]Związek Harcerstwa Bajtockiego Description 给定一棵有n个点的无根树,相邻的点之间的距离为1,一开始你位于m点. ...

  6. luogu2155 [SDOI2008]沙拉公主的困惑

    link 求出1到N的阶乘中与M的阶乘互质的数的个数,对R取模,多组询问,R<=10^9+10,T<=10000,1 < = N , M < = 10000000 1到\(M! ...

  7. 编译 OpenWrt/LEDE 基本过程

    说明 前段时间花 110 从闲鱼淘了个 Newifi D1,这个路由的 Soc 是 MT7621AT,性能强劲,于是又开始折腾编译固件了,重新记录一下编译基本过程. 步骤 安装必要的软件包 sudo ...

  8. CSS(十三).高度如何铺满全屏

    该需求来源一次面试题. IE6不认识!important声明,IE7.IE8.Firefox.Chrome等浏览器认识:而在怪异模式中,IE6/7/8都不认识!important声明,这只是区别的一种 ...

  9. [Shell]Shell学习笔记之for

    关于shell中的for循环用法很多,一直想总结一下,今天网上看到上一篇关于for循环用法的总结,感觉很全面,所以就转过来研究研究,嘿嘿…1. for((i=1;i<=10;i++));do e ...

  10. Mysql-proxy代理内网数据库

    Mysql-proxy 参考:https://segmentfault.com/q/1010000000394160 情景分析:首先您需要正在使用UCloud云主机(uhoust)以及云数据库(udb ...