Conclusion:
Theme Upload logo will do the following things:
(1) Using Uploadportletrequest object to handle the <input of the page type=file>
(2) for the uploaded logo picture is empty, then throw an exception.
(3) for the upload of the logo picture is not empty, the first from the database to find the current layout, for logo definition logoid, and bar logoid add to the current layout and then back to the database, and then set according to the Boolean variable to determine whether it is the logo associated to the hook, And whether this logo image should be persisted.
Process display:
When one of the theme in the Liferay chooses to upload the logo and clicks the "Save" button:
As shown below
Specific analysis:
It's going to trigger the struts action/group_pages/edit_layout_set, and we'll find the matching option in 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>
The
can find that its corresponding action class is the Updatelogo method of the Editlayoutsetaction class:
protected void Updatelogo (Actionrequest actionrequest, Long livegroupid, long staginggroupid, Boolean privatelayout, Boolean Haslogo) throws Exception {Uploadportletrequest Uploadportletreque
st = 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 (s)
Taginggroupid, Privatelayout, Uselogo, InputStream, false);
}} finally {Streamutil.cleanup (inputstream); }
}