我正在尝试使用元数据上传文档。简单文件上传器portlet工作正常,但当我尝试附加元数据时,它发送请求失败错误
这是我的代码
public DLFileEntry upload(ActionRequest request, ActionResponse response) throws Exception
{
// TODO Auto-generated method stub
ServiceContext sc = new ServiceContext();
Date date1 = (Date) request.getAttribute("efrom");
Date date2 = (Date) request.getAttribute("efrom");
String getTitle = request.getParameter("Title");
String getDesc = request.getParameter("Description");
String CKEditor = request.getParameter("CKE");
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long defaultRepoId = DLFolderConstants.getDataRepositoryId(themeDisplay.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
String rtfoutput = FileIO.readFromFile(tPath);
File tempFile = new File(tPath);
InputStream is = new FileInputStream(tempFile);
Folder folderName = DLAppLocalServiceUtil.getFolder(defaultRepoId, 0, "Folder Name");
long folderId = folderName.getFolderId();
long repositoryId = folderName.getRepositoryId();
byte[] bytes = rtfoutput.getBytes();
Map<String, Fields > fieldsMap = new HashMap<String, Fields >();
Fields targetFields = new Fields();
targetFields.put(new Field("Effective-To", date1));
targetFields.put(new Field("Effective-From", date2));
fieldsMap.put("", targetFields);
DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil.addFileEntry(defaultRepoId, 0L, repositoryId, folderId, getTitle+".rtf", "RichTextFormat", getTitle, StringPool.BLANK, StringPool.BLANK, 0L,
fieldsMap, tempFile, is, tempFile.getTotalSpace(), sc);
return dlFileEntry;
}
我不明白为什么这说请求失败
date1和date2是我试图通过文档获取的元细节
答案 0 :(得分:1)
我认为你不能简单地添加自定义元数据。每个FileEntryType都有一个可能的DDMStructure描述的metada字段集合。但是,您应首先创建/更新FileType的DDMS结构,然后再放置新的MetaData。有关详细信息,请参阅liferay的源代码和这篇文章:http://www.liferay.com/de/community/forums/-/message_boards/message/13460906