结论:
theme上传logo会做以下事情:
(1)用UploadPortletRequest对象来处理页面的<input type=file>
(2)对于上传的logo图片为空,则抛出异常。
(3)对于上传的logo图片不为空,则先从数据库中找到当前layout,为logo定义logoId,并吧logoId添加到当前layout并存回数据库,然后根据布尔变量设定,来决定是否吧这个logo关联到hook,以及这个这个logo图片是否要持久化。
过程展示:
当在Liferay中的某个theme选择上传logo,并点击"save"按钮:
如下所示
具体分析:
它会去触发struts动作/group_pages/edit_layout_set,我们在struts-config.xml中找到匹配选项:
<action path="/group_pages/edit_layout_set" type="com.liferay.portlet.layoutsadmin.action.EditLayoutSetAction"> <forward name="portlet.layouts_admin.edit_layouts" path="portlet.layouts_admin.edit_layouts" /> <forward name="portlet.layouts_admin.error" path="portlet.layouts_admin.error" /> </action>
可以发现,它对应的动作类是EditLayoutSetAction类的updateLogo方法:
protected void updateLogo( ActionRequest actionRequest, long liveGroupId, long stagingGroupId, boolean privateLayout, boolean hasLogo) throws Exception { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); boolean useLogo = ParamUtil.getBoolean(actionRequest, "useLogo"); InputStream inputStream = null; try { File file = uploadPortletRequest.getFile("logoFileName"); if (useLogo && !file.exists()) { if (hasLogo) { return; } throw new UploadException("No logo uploaded for use"); } if (file.exists()) { inputStream = new ByteArrayFileInputStream(file, 1024); } if (inputStream != null) { inputStream.mark(0); } LayoutSetServiceUtil.updateLogo( liveGroupId, privateLayout, useLogo, inputStream, false); if (inputStream != null) { inputStream.reset(); } if (stagingGroupId > 0) { LayoutSetServiceUtil.updateLogo( stagingGroupId, privateLayout, useLogo, inputStream, false); } } finally { StreamUtil.cleanUp(inputStream); } }
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索inputstream
logo
liferay theme、liferay theme 开发、liferay 7 theme开发、liferay theme js、liferay 7.0 theme,以便于您获取更多的相关知识。
时间: 2024-10-16 03:33:35