Detailed analysis of Liferay theme upload logo

Source: Internet
Author: User
Tags empty

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); } 
    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.