Example usage for com.liferay.portal.kernel.exception LayoutPrototypeException LayoutPrototypeException

List of usage examples for com.liferay.portal.kernel.exception LayoutPrototypeException LayoutPrototypeException

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.exception LayoutPrototypeException LayoutPrototypeException.

Prototype

public LayoutPrototypeException(Throwable cause) 

Source Link

Usage

From source file:com.liferay.exportimport.controller.LayoutImportController.java

License:Open Source License

protected void validateLayoutPrototypes(long companyId, Element headerElement, Element layoutsElement)
        throws Exception {

    List<Tuple> missingLayoutPrototypes = new ArrayList<>();

    String layoutSetPrototypeUuid = headerElement.attributeValue("layout-set-prototype-uuid");

    if (Validator.isNotNull(layoutSetPrototypeUuid)) {
        try {//  w  ww .j ava  2s.  c  om
            _layoutSetPrototypeLocalService.getLayoutSetPrototypeByUuidAndCompanyId(layoutSetPrototypeUuid,
                    companyId);
        } catch (NoSuchLayoutSetPrototypeException nslspe) {

            // LPS-52675

            if (_log.isDebugEnabled()) {
                _log.debug(nslspe, nslspe);
            }

            String layoutSetPrototypeName = headerElement.attributeValue("layout-set-prototype-name");

            missingLayoutPrototypes.add(new Tuple(LayoutSetPrototype.class.getName(), layoutSetPrototypeUuid,
                    layoutSetPrototypeName));
        }
    }

    List<Element> layoutElements = layoutsElement.elements();

    for (Element layoutElement : layoutElements) {
        String action = layoutElement.attributeValue(Constants.ACTION);

        if (action.equals(Constants.SKIP)) {
            continue;
        }

        String layoutPrototypeUuid = GetterUtil
                .getString(layoutElement.attributeValue("layout-prototype-uuid"));

        if (Validator.isNotNull(layoutPrototypeUuid)) {
            try {
                _layoutPrototypeLocalService.getLayoutPrototypeByUuidAndCompanyId(layoutPrototypeUuid,
                        companyId);
            } catch (NoSuchLayoutPrototypeException nslpe) {

                // LPS-52675

                if (_log.isDebugEnabled()) {
                    _log.debug(nslpe, nslpe);
                }

                String layoutPrototypeName = GetterUtil
                        .getString(layoutElement.attributeValue("layout-prototype-name"));

                missingLayoutPrototypes.add(
                        new Tuple(LayoutPrototype.class.getName(), layoutPrototypeUuid, layoutPrototypeName));
            }
        }
    }

    if (!missingLayoutPrototypes.isEmpty()) {
        throw new LayoutPrototypeException(missingLayoutPrototypes);
    }
}