SOS-1448 reuse code from core --> Requieres portal#9112

Requieres https://github.com/brianchandotcom/liferay-portal/pull/9112