LPS-43974 Use the same logic in PortletContainerImp._doPreparePortlet

LPS-43974 and LPS-42531