06、ドキュメントやライブラリにファイルをアップロードしたいのですが、検索してこのようなコードを書いたところ、無効なプロパティ変更ログのエラーが発生しました。誰でも私のコードを修正できますか? また、リポジトリ ID と会社 ID が同じであるという別の疑いがありますか? 無効なデータを入力したことを示すポートレットに表示されます。もう一度やり直してください。
public void uploadBook(ActionRequest actionRequest,
ActionResponse actionRresponse) throws PortletException,
IOException, com.liferay.portal.kernel.exception.PortalException, com.liferay.portal.kernel.exception.SystemException {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
String submissionFileName = uploadRequest.getFileName("file");//uploaded filename
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
File file = uploadRequest.getFile("file");
String contentType = MimeTypesUtil.getContentType(file);
InputStream inputStream = new FileInputStream(file);
String folderName="library";
long folderId = 11502;
long repositoryId =10132;
//java.io.File file = ( java.io.File)uploadRequest.getFile("file");
// InputStream is = new FileInputStream(file);
DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.addFileEntry(themeDisplay.getUserId(),
repositoryId,
folderId,
file.getName(),
contentType,
submissionFileName,
"no description",
"changeLog",
inputStream,
file.length(),
serviceContext);
//addFileEntry(long userId, long groupId, long folderId, String name, String title, String description, String changeLog, String extraSettings, byte[] bytes, ServiceContext serviceContext)
String successMessage ="File Uploaded Successfully";
SessionMessages.add(actionRequest, "request_rocessed",successMessage);
}