Example usage for com.liferay.portal.kernel.model LayoutPrototype getGroupId

List of usage examples for com.liferay.portal.kernel.model LayoutPrototype getGroupId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model LayoutPrototype getGroupId.

Prototype

public long getGroupId() throws com.liferay.portal.kernel.exception.PortalException;

Source Link

Usage

From source file:com.liferay.layout.prototype.internal.exportimport.data.handler.LayoutPrototypeStagedModelDataHandler.java

License:Open Source License

@Override
protected void doImportStagedModel(PortletDataContext portletDataContext, LayoutPrototype layoutPrototype)
        throws Exception {

    long userId = portletDataContext.getUserId(layoutPrototype.getUserUuid());

    ServiceContext serviceContext = portletDataContext.createServiceContext(layoutPrototype);

    serviceContext.setAttribute("addDefaultLayout", Boolean.FALSE);

    LayoutPrototype importedLayoutPrototype = null;

    if (portletDataContext.isDataStrategyMirror()) {
        LayoutPrototype existingLayoutPrototype = _layoutPrototypeLocalService
                .fetchLayoutPrototypeByUuidAndCompanyId(layoutPrototype.getUuid(),
                        portletDataContext.getCompanyId());

        if (existingLayoutPrototype == null) {
            serviceContext.setUuid(layoutPrototype.getUuid());

            importedLayoutPrototype = _layoutPrototypeLocalService.addLayoutPrototype(userId,
                    portletDataContext.getCompanyId(), layoutPrototype.getNameMap(),
                    layoutPrototype.getDescriptionMap(), layoutPrototype.isActive(), serviceContext);
        } else {/*from ww w.  j ava2s  . c  o m*/
            importedLayoutPrototype = _layoutPrototypeLocalService.updateLayoutPrototype(
                    existingLayoutPrototype.getLayoutPrototypeId(), layoutPrototype.getNameMap(),
                    layoutPrototype.getDescriptionMap(), layoutPrototype.isActive(), serviceContext);
        }
    } else {
        importedLayoutPrototype = _layoutPrototypeLocalService.addLayoutPrototype(userId,
                portletDataContext.getCompanyId(), layoutPrototype.getNameMap(),
                layoutPrototype.getDescriptionMap(), layoutPrototype.isActive(), serviceContext);
    }

    importLayouts(portletDataContext, layoutPrototype, importedLayoutPrototype.getGroupId());

    portletDataContext.importClassedModel(layoutPrototype, importedLayoutPrototype);
}

From source file:com.liferay.layout.prototype.internal.exportimport.data.handler.LayoutPrototypeStagedModelDataHandler.java

License:Open Source License

protected void exportLayouts(PortletDataContext portletDataContext, LayoutPrototype layoutPrototype)
        throws Exception {

    long groupId = portletDataContext.getGroupId();
    boolean privateLayout = portletDataContext.isPrivateLayout();
    long scopeGroupId = portletDataContext.getScopeGroupId();

    List<Layout> layouts = _layoutLocalService.getLayouts(layoutPrototype.getGroupId(), true,
            LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);

    try {/*from w  w w  . j a va 2 s.  c  om*/
        portletDataContext.setGroupId(layoutPrototype.getGroupId());
        portletDataContext.setPrivateLayout(true);
        portletDataContext.setScopeGroupId(layoutPrototype.getGroupId());

        for (Layout layout : layouts) {
            StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, layoutPrototype, layout,
                    PortletDataContext.REFERENCE_TYPE_EMBEDDED);
        }
    } finally {
        portletDataContext.setGroupId(groupId);
        portletDataContext.setPrivateLayout(privateLayout);
        portletDataContext.setScopeGroupId(scopeGroupId);
    }
}

From source file:com.liferay.layout.prototype.internal.exportimport.data.handler.test.LayoutPrototypeStagedModelDataHandlerTest.java

License:Open Source License

@Override
protected void validateImport(StagedModel stagedModel, StagedModelAssets stagedModelAssets,
        Map<String, List<StagedModel>> dependentStagedModelsMap, Group group) throws Exception {

    LayoutPrototype importedLayoutPrototype = (LayoutPrototype) getStagedModel(stagedModel.getUuid(), group);

    Assert.assertNotNull(importedLayoutPrototype);

    List<StagedModel> layoutDependentStagedModels = dependentStagedModelsMap.get(Layout.class.getSimpleName());

    Assert.assertEquals(layoutDependentStagedModels.toString(), 1, layoutDependentStagedModels.size());

    Layout layout = (Layout) layoutDependentStagedModels.get(0);

    Layout importedLayout = LayoutLocalServiceUtil.fetchLayoutByUuidAndGroupId(layout.getUuid(),
            importedLayoutPrototype.getGroupId(), layout.isPrivateLayout());

    Assert.assertNotNull(importedLayout);
    Assert.assertEquals(//  w  w w.  j  a v a  2s. c o m
            layout.getTypeSettingsProperty(LayoutPrototypeStagedModelDataHandlerTest.class.getName()),
            importedLayout.getTypeSettingsProperty(LayoutPrototypeStagedModelDataHandlerTest.class.getName()));

    List<StagedModel> layoutFriendlyURLDependentStagedModels = dependentStagedModelsMap
            .get(LayoutFriendlyURL.class.getSimpleName());

    LayoutFriendlyURL layoutFriendlyURL = (LayoutFriendlyURL) layoutFriendlyURLDependentStagedModels.get(0);

    LayoutFriendlyURL importedLayoutFriendlyURL = LayoutFriendlyURLLocalServiceUtil
            .fetchLayoutFriendlyURLByUuidAndGroupId(layoutFriendlyURL.getUuid(), importedLayout.getGroupId());

    Assert.assertNotNull(importedLayoutFriendlyURL);
    Assert.assertEquals(layoutFriendlyURL.getFriendlyURL(), importedLayoutFriendlyURL.getFriendlyURL());
}

From source file:com.liferay.layout.set.prototype.exportimport.data.handler.test.LayoutSetPrototypeStagedModelDataHandlerTest.java

License:Open Source License

protected void validateLayouts(LayoutSetPrototype importedLayoutSetPrototype,
        LayoutPrototype importedLayoutPrototype, Layout layoutSetPrototypeLayout) throws Exception {

    validatePrototypedLayouts(LayoutSetPrototype.class, importedLayoutSetPrototype.getGroupId());
    validatePrototypedLayouts(LayoutPrototype.class, importedLayoutPrototype.getGroupId());

    Assert.assertNotNull(layoutSetPrototypeLayout.getLayoutPrototypeUuid());

    Layout importedLayout = LayoutLocalServiceUtil.fetchLayoutByUuidAndGroupId(
            layoutSetPrototypeLayout.getUuid(), importedLayoutSetPrototype.getGroupId(), true);

    Assert.assertNotNull(importedLayout);
    Assert.assertEquals(importedLayoutSetPrototype.getGroupId(), importedLayout.getGroupId());
    Assert.assertEquals(importedLayoutPrototype.getUuid(), importedLayout.getLayoutPrototypeUuid());
}