Example usage for com.liferay.portal.kernel.model Group getStagingGroup

List of usage examples for com.liferay.portal.kernel.model Group getStagingGroup

Introduction

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

Prototype

public Group getStagingGroup();

Source Link

Usage

From source file:com.liferay.calendar.service.test.CalendarServiceTest.java

License:Open Source License

@Sync
@Test/*from www  .j  ava 2  s .c o m*/
public void testIsManageableFromGroup() throws Exception {
    Group liveGroup = GroupTestUtil.addGroup();

    GroupTestUtil.enableLocalStaging(liveGroup);

    Group notStagedGroup = GroupTestUtil.addGroup();

    Group stagingGroup = liveGroup.getStagingGroup();

    User adminUser = UserTestUtil.addOmniAdminUser();

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(adminUser)) {

        Calendar notStagedCalendar = getGroupCalendar(notStagedGroup);

        Assert.assertTrue(CalendarServiceUtil.isManageableFromGroup(notStagedCalendar.getCalendarId(),
                notStagedGroup.getGroupId()));
        Assert.assertTrue(CalendarServiceUtil.isManageableFromGroup(notStagedCalendar.getCalendarId(),
                liveGroup.getGroupId()));
        Assert.assertTrue(CalendarServiceUtil.isManageableFromGroup(notStagedCalendar.getCalendarId(),
                stagingGroup.getGroupId()));

        Calendar liveCalendar = getGroupCalendar(liveGroup);

        Assert.assertFalse(CalendarServiceUtil.isManageableFromGroup(liveCalendar.getCalendarId(),
                notStagedGroup.getGroupId()));
        Assert.assertFalse(CalendarServiceUtil.isManageableFromGroup(liveCalendar.getCalendarId(),
                liveGroup.getGroupId()));
        Assert.assertFalse(CalendarServiceUtil.isManageableFromGroup(liveCalendar.getCalendarId(),
                stagingGroup.getGroupId()));

        Calendar stagingCalendar = getGroupCalendar(stagingGroup);

        Assert.assertFalse(CalendarServiceUtil.isManageableFromGroup(stagingCalendar.getCalendarId(),
                notStagedGroup.getGroupId()));
        Assert.assertFalse(CalendarServiceUtil.isManageableFromGroup(stagingCalendar.getCalendarId(),
                liveGroup.getGroupId()));
        Assert.assertTrue(CalendarServiceUtil.isManageableFromGroup(stagingCalendar.getCalendarId(),
                stagingGroup.getGroupId()));
    } finally {
        GroupLocalServiceUtil.deleteGroup(liveGroup);
        GroupLocalServiceUtil.deleteGroup(notStagedGroup);
        UserLocalServiceUtil.deleteUser(adminUser);
    }
}

From source file:com.liferay.calendar.test.util.CalendarStagingTestUtil.java

License:Open Source License

public static Calendar getStagingCalendar(Group group, Calendar calendar) throws PortalException {

    if (group.hasStagingGroup()) {
        group = group.getStagingGroup();
    }/*from  w  ww.  j  a v  a  2 s . co  m*/

    Assert.assertTrue(group.isStaged());

    return CalendarLocalServiceUtil.fetchCalendarByUuidAndGroupId(calendar.getUuid(), group.getGroupId());
}

From source file:com.liferay.calendar.test.util.CalendarStagingTestUtil.java

License:Open Source License

public static void publishLayouts(Group liveGroup, boolean enableCalendarStaging) throws PortalException {

    Group stagingGroup = liveGroup.getStagingGroup();

    Map<String, String[]> parameters = ExportImportConfigurationParameterMapFactory.buildParameterMap();

    addStagingAttribute(parameters, PortletDataHandlerKeys.DELETIONS, true);
    addStagingAttribute(parameters, PortletDataHandlerKeys.PORTLET_CONFIGURATION_ALL, false);
    addStagingAttribute(parameters,//from  w  w w  .j  av  a 2s. com
            PortletDataHandlerKeys.PORTLET_DATA + StringPool.UNDERLINE + CalendarPortletKeys.CALENDAR,
            enableCalendarStaging);
    addStagingAttribute(parameters, PortletDataHandlerKeys.PORTLET_DATA_ALL, false);
    addStagingAttribute(parameters, PortletDataHandlerKeys.PORTLET_SETUP_ALL, false);

    StagingUtil.publishLayouts(TestPropsValues.getUserId(), stagingGroup.getGroupId(), liveGroup.getGroupId(),
            false, parameters);
}

From source file:com.liferay.calendar.web.internal.display.context.CalendarDisplayContext.java

License:Open Source License

public List<Calendar> getOtherCalendars(long[] calendarIds) throws PortalException {

    List<Calendar> otherCalendars = new ArrayList<>();

    for (long calendarId : calendarIds) {
        Calendar calendar = _calendarService.fetchCalendar(calendarId);

        if (calendar == null) {
            continue;
        }/* w  ww.  j a v  a2  s  .c  o  m*/

        CalendarResource calendarResource = calendar.getCalendarResource();

        if (!calendarResource.isActive()) {
            continue;
        }

        Group scopeGroup = _themeDisplay.getScopeGroup();

        long scopeGroupId = scopeGroup.getGroupId();
        long scopeLiveGroupId = scopeGroup.getLiveGroupId();

        Group calendarGroup = _groupLocalService.getGroup(calendar.getGroupId());

        long calendarGroupId = calendarGroup.getGroupId();

        if (scopeGroup.isStagingGroup()) {
            if (calendarGroup.isStagingGroup()) {
                if (scopeGroupId != calendarGroupId) {
                    calendar = _calendarLocalService.fetchCalendarByUuidAndGroupId(calendar.getUuid(),
                            calendarGroup.getLiveGroupId());
                }
            } else if (scopeLiveGroupId == calendarGroupId) {
                Group stagingGroup = calendarGroup.getStagingGroup();

                calendar = _calendarLocalService.fetchCalendarByUuidAndGroupId(calendar.getUuid(),
                        stagingGroup.getGroupId());
            }
        } else if (calendarGroup.isStagingGroup()) {
            calendar = _calendarLocalService.fetchCalendarByUuidAndGroupId(calendar.getUuid(),
                    calendarGroup.getLiveGroupId());
        }

        if (calendar == null) {
            continue;
        }

        otherCalendars.add(calendar);
    }

    return otherCalendars;
}

From source file:com.liferay.calendar.web.internal.portlet.CalendarPortlet.java

License:Open Source License

protected void serveCalendarResources(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String keywords = ParamUtil.getString(resourceRequest, "keywords");

    Set<Calendar> calendarsSet = new LinkedHashSet<>();

    Hits hits = search(themeDisplay, keywords);

    for (Document document : hits.getDocs()) {
        long calendarId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

        Calendar calendar = _calendarService.getCalendar(calendarId);

        CalendarResource calendarResource = calendar.getCalendarResource();

        if (calendarResource.isActive()) {
            Group group = _groupLocalService.getGroup(calendar.getGroupId());

            if (group.hasStagingGroup()) {
                Group stagingGroup = group.getStagingGroup();

                long stagingGroupId = stagingGroup.getGroupId();

                if (stagingGroupId == themeDisplay.getScopeGroupId()) {
                    calendar = _calendarLocalService.fetchCalendarByUuidAndGroupId(calendar.getUuid(),
                            stagingGroupId);
                }/*from  w ww . j  a va 2  s . com*/
            }

            calendarsSet.add(calendar);
        }
    }

    String name = StringUtil.merge(CustomSQLUtil.keywords(keywords), StringPool.BLANK);

    LinkedHashMap<String, Object> params = new LinkedHashMap<>();

    params.put("usersGroups", themeDisplay.getUserId());

    List<Group> groups = _groupLocalService.search(themeDisplay.getCompanyId(), name, null, params, true, 0,
            SearchContainer.DEFAULT_DELTA);

    for (Group group : groups) {
        long groupClassNameId = _portal.getClassNameId(Group.class);

        addCalendar(resourceRequest, calendarsSet, groupClassNameId, group.getGroupId());
    }

    long userClassNameId = _portal.getClassNameId(User.class);

    List<User> users = _userLocalService.search(themeDisplay.getCompanyId(), keywords, 0, null, 0,
            SearchContainer.DEFAULT_DELTA, new UserFirstNameComparator());

    for (User user : users) {
        addCalendar(resourceRequest, calendarsSet, userClassNameId, user.getUserId());
    }

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    for (Calendar calendar : calendarsSet) {
        JSONObject jsonObject = CalendarUtil.toCalendarJSONObject(themeDisplay, calendar);

        jsonArray.put(jsonObject);
    }

    writeJSON(resourceRequest, resourceResponse, jsonArray);
}

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

License:Open Source License

public void exportPortlet(PortletDataContext portletDataContext, long plid, Element parentElement,
        boolean exportPermissions, boolean exportPortletArchivedSetups, boolean exportPortletData,
        boolean exportPortletSetup, boolean exportPortletUserPreferences) throws Exception {

    long layoutId = LayoutConstants.DEFAULT_PARENT_LAYOUT_ID;

    Layout layout = _layoutLocalService.fetchLayout(plid);

    if (layout != null) {
        layoutId = layout.getLayoutId();
    }/*w w w  .jav a 2 s .  c  o m*/

    Portlet portlet = _portletLocalService.getPortletById(portletDataContext.getCompanyId(),
            portletDataContext.getPortletId());

    if ((portlet == null) || portlet.isUndeployedPortlet()) {
        if (_log.isDebugEnabled()) {
            _log.debug("Do not export portlet " + portletDataContext.getPortletId()
                    + " because the portlet is not deployed");
        }

        return;
    }

    if (!portlet.isInstanceable() && !portlet.isPreferencesUniquePerLayout()
            && portletDataContext.hasNotUniquePerLayout(portletDataContext.getPortletId())) {

        return;
    }

    if (BackgroundTaskThreadLocal.hasBackgroundTask()) {
        PortletDataContext clonedPortletDataContext = _portletDataContextFactory
                .clonePortletDataContext(portletDataContext);

        ManifestSummary manifestSummary = clonedPortletDataContext.getManifestSummary();

        manifestSummary.resetCounters();

        PortletDataHandler portletDataHandler = portlet.getPortletDataHandlerInstance();

        portletDataHandler.prepareManifestSummary(clonedPortletDataContext);

        _portletDataHandlerStatusMessageSender.sendStatusMessage("portlet", portletDataContext.getPortletId(),
                manifestSummary);
    }

    Document document = SAXReaderUtil.createDocument();

    Element portletElement = document.addElement("portlet");

    portletElement.addAttribute("portlet-id", portletDataContext.getPortletId());
    portletElement.addAttribute("root-portlet-id", portletDataContext.getRootPortletId());
    portletElement.addAttribute("old-plid", String.valueOf(plid));
    portletElement.addAttribute("scope-group-id", String.valueOf(portletDataContext.getScopeGroupId()));
    portletElement.addAttribute("scope-layout-type", portletDataContext.getScopeType());
    portletElement.addAttribute("scope-layout-uuid", portletDataContext.getScopeLayoutUuid());
    portletElement.addAttribute("private-layout", String.valueOf(portletDataContext.isPrivateLayout()));

    // Data

    if (exportPortletData) {
        javax.portlet.PortletPreferences jxPortletPreferences = null;

        if (ExportImportThreadLocal.isInitialLayoutStagingInProcess()) {
            if (layout != null) {
                Group liveGroup = layout.getGroup();

                Group stagingGroup = liveGroup.getStagingGroup();

                layout.setGroupId(stagingGroup.getGroupId());

                jxPortletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(layout,
                        portletDataContext.getPortletId());

                layout.setGroupId(liveGroup.getGroupId());
            } else {
                Group liveGroup = _groupLocalService.getGroup(portletDataContext.getGroupId());

                Group stagingGroup = liveGroup.getStagingGroup();

                jxPortletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(
                        portletDataContext.getCompanyId(), stagingGroup.getGroupId(),
                        portletDataContext.getPortletId());
            }
        } else {
            if (layout != null) {
                jxPortletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(layout,
                        portletDataContext.getPortletId());
            } else {
                jxPortletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(
                        portletDataContext.getCompanyId(), portletDataContext.getGroupId(),
                        portletDataContext.getPortletId());
            }
        }

        if (!portlet.isPreferencesUniquePerLayout()) {
            StringBundler sb = new StringBundler(5);

            sb.append(portletDataContext.getPortletId());
            sb.append(StringPool.AT);
            sb.append(portletDataContext.getScopeType());
            sb.append(StringPool.AT);
            sb.append(portletDataContext.getScopeLayoutUuid());

            String dataKey = sb.toString();

            if (!portletDataContext.hasNotUniquePerLayout(dataKey)) {
                portletDataContext.putNotUniquePerLayout(dataKey);

                exportPortletData(portletDataContext, portlet, layout, jxPortletPreferences, portletElement);
            }
        } else {
            exportPortletData(portletDataContext, portlet, layout, jxPortletPreferences, portletElement);
        }
    }

    // Portlet preferences

    if (exportPortletSetup) {

        // Company

        exportPortletPreferences(portletDataContext, portletDataContext.getCompanyId(),
                PortletKeys.PREFS_OWNER_TYPE_COMPANY, false, layout, plid, portlet.getRootPortletId(),
                portletElement);

        // Group

        exportPortletPreferences(portletDataContext, portletDataContext.getScopeGroupId(),
                PortletKeys.PREFS_OWNER_TYPE_GROUP, false, layout, PortletKeys.PREFS_PLID_SHARED,
                portlet.getRootPortletId(), portletElement);

        // Group embedded portlets

        exportPortletPreferences(portletDataContext, portletDataContext.getScopeGroupId(),
                PortletKeys.PREFS_OWNER_TYPE_LAYOUT, false, layout, PortletKeys.PREFS_PLID_SHARED,
                portlet.getPortletId(), portletElement);

        // Layout

        exportPortletPreferences(portletDataContext, PortletKeys.PREFS_OWNER_ID_DEFAULT,
                PortletKeys.PREFS_OWNER_TYPE_LAYOUT, false, layout, plid, portletDataContext.getPortletId(),
                portletElement);
    }

    // Portlet user preferences

    if (exportPortletUserPreferences) {
        List<PortletPreferences> portletPreferencesList = _portletPreferencesLocalService.getPortletPreferences(
                PortletKeys.PREFS_OWNER_TYPE_USER, plid, portletDataContext.getPortletId());

        for (PortletPreferences portletPreferences : portletPreferencesList) {

            boolean defaultUser = false;

            if (portletPreferences.getOwnerId() == PortletKeys.PREFS_OWNER_ID_DEFAULT) {

                defaultUser = true;
            }

            exportPortletPreferences(portletDataContext, portletPreferences.getOwnerId(),
                    PortletKeys.PREFS_OWNER_TYPE_USER, defaultUser, layout, plid,
                    portletDataContext.getPortletId(), portletElement);
        }

        try {
            PortletPreferences groupPortletPreferences = _portletPreferencesLocalService.getPortletPreferences(
                    portletDataContext.getScopeGroupId(), PortletKeys.PREFS_OWNER_TYPE_GROUP,
                    PortletKeys.PREFS_PLID_SHARED, portlet.getRootPortletId());

            exportPortletPreference(portletDataContext, portletDataContext.getScopeGroupId(),
                    PortletKeys.PREFS_OWNER_TYPE_GROUP, false, groupPortletPreferences,
                    portlet.getRootPortletId(), PortletKeys.PREFS_PLID_SHARED, portletElement);
        } catch (NoSuchPortletPreferencesException nsppe) {

            // LPS-52675

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

    // Archived setups

    if (exportPortletArchivedSetups) {
        List<PortletItem> portletItems = _portletItemLocalService.getPortletItems(
                portletDataContext.getGroupId(), portletDataContext.getRootPortletId(),
                PortletPreferences.class.getName());

        for (PortletItem portletItem : portletItems) {
            exportPortletPreferences(portletDataContext, portletItem.getPortletItemId(),
                    PortletKeys.PREFS_OWNER_TYPE_ARCHIVED, false, null, plid, portletItem.getPortletId(),
                    portletElement);
        }
    }

    // Permissions

    if (exportPermissions) {
        _permissionExporter.exportPortletPermissions(portletDataContext, portletDataContext.getPortletId(),
                layout, portletElement);
    }

    // Zip

    StringBundler pathSB = new StringBundler(4);

    pathSB.append(ExportImportPathUtil.getPortletPath(portletDataContext));
    pathSB.append(StringPool.SLASH);
    pathSB.append(plid);
    pathSB.append("/portlet.xml");

    String path = pathSB.toString();

    Element element = parentElement.addElement("portlet");

    element.addAttribute("portlet-id", portletDataContext.getPortletId());
    element.addAttribute("layout-id", String.valueOf(layoutId));
    element.addAttribute("path", path);
    element.addAttribute("portlet-data", String.valueOf(exportPortletData));

    PortletDataHandler portletDataHandler = portlet.getPortletDataHandlerInstance();

    element.addAttribute("schema-version", portletDataHandler.getSchemaVersion());

    StringBundler configurationOptionsSB = new StringBundler(6);

    if (exportPortletSetup) {
        configurationOptionsSB.append("setup");
        configurationOptionsSB.append(StringPool.COMMA);
    }

    if (exportPortletArchivedSetups) {
        configurationOptionsSB.append("archived-setups");
        configurationOptionsSB.append(StringPool.COMMA);
    }

    if (exportPortletUserPreferences) {
        configurationOptionsSB.append("user-preferences");
        configurationOptionsSB.append(StringPool.COMMA);
    }

    if (configurationOptionsSB.index() > 0) {
        configurationOptionsSB.setIndex(configurationOptionsSB.index() - 1);
    }

    element.addAttribute("portlet-configuration", configurationOptionsSB.toString());

    try {
        portletDataContext.addZipEntry(path, document.formattedString());
    } catch (IOException ioe) {
        if (_log.isWarnEnabled()) {
            _log.warn(ioe.getMessage());
        }
    }
}

From source file:com.liferay.exportimport.internal.background.task.LayoutStagingBackgroundTaskExecutor.java

License:Open Source License

@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws PortalException {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap();

    long userId = MapUtil.getLong(settingsMap, "userId");
    long targetGroupId = MapUtil.getLong(settingsMap, "targetGroupId");
    long sourceGroupId = MapUtil.getLong(settingsMap, "sourceGroupId");

    clearBackgroundTaskStatus(backgroundTask);

    File file = null;//from  w  w  w . j av a 2s .  c  om
    MissingReferences missingReferences = null;

    try {
        ExportImportThreadLocal.setLayoutStagingInProcess(true);

        Group targetGroup = GroupLocalServiceUtil.fetchGroup(targetGroupId);

        if (targetGroup == null) {
            throw new NoSuchGroupException(
                    "Target group does not exists with the primary key " + targetGroupId);
        }

        Group sourceGroup = GroupLocalServiceUtil.getGroup(sourceGroupId);

        if (sourceGroup.hasStagingGroup()) {
            Group stagingGroup = sourceGroup.getStagingGroup();

            if (stagingGroup.getGroupId() == targetGroupId) {
                ExportImportThreadLocal.setInitialLayoutStagingInProcess(true);

                TrashEntryLocalServiceUtil.deleteEntries(sourceGroupId, true);
            }
        }

        ExportImportLifecycleManagerUtil.fireExportImportLifecycleEvent(EVENT_PUBLICATION_LAYOUT_LOCAL_STARTED,
                PROCESS_FLAG_LAYOUT_STAGING_IN_PROCESS,
                String.valueOf(exportImportConfiguration.getExportImportConfigurationId()),
                exportImportConfiguration);

        boolean privateLayout = MapUtil.getBoolean(settingsMap, "privateLayout");

        initThreadLocals(sourceGroupId, privateLayout);

        file = ExportImportLocalServiceUtil.exportLayoutsAsFile(exportImportConfiguration);

        markBackgroundTask(backgroundTask.getBackgroundTaskId(), "exported");

        missingReferences = TransactionInvokerUtil.invoke(transactionConfig,
                new LayoutStagingImportCallable(backgroundTask.getBackgroundTaskId(), exportImportConfiguration,
                        file, sourceGroupId, targetGroupId, userId));

        ExportImportThreadLocal.setInitialLayoutStagingInProcess(false);
        ExportImportThreadLocal.setLayoutStagingInProcess(false);

        ExportImportLifecycleManagerUtil.fireExportImportLifecycleEvent(
                EVENT_PUBLICATION_LAYOUT_LOCAL_SUCCEEDED, PROCESS_FLAG_LAYOUT_STAGING_IN_PROCESS,
                String.valueOf(exportImportConfiguration.getExportImportConfigurationId()),
                exportImportConfiguration);
    } catch (Throwable t) {
        ExportImportThreadLocal.setInitialLayoutStagingInProcess(false);
        ExportImportThreadLocal.setLayoutStagingInProcess(false);

        ExportImportLifecycleManagerUtil.fireExportImportLifecycleEvent(EVENT_PUBLICATION_LAYOUT_LOCAL_FAILED,
                PROCESS_FLAG_LAYOUT_STAGING_IN_PROCESS,
                String.valueOf(exportImportConfiguration.getExportImportConfigurationId()),
                exportImportConfiguration, t);

        if (_log.isDebugEnabled()) {
            _log.debug(t, t);
        } else if (_log.isWarnEnabled()) {
            _log.warn("Unable to publish layout: " + t.getMessage());
        }

        Group sourceGroup = GroupLocalServiceUtil.getGroup(sourceGroupId);

        if (sourceGroup.hasStagingGroup()) {
            ServiceContext serviceContext = new ServiceContext();

            serviceContext.setUserId(userId);

            StagingLocalServiceUtil.disableStaging(sourceGroup, serviceContext);

            List<BackgroundTask> queuedBackgroundTasks = BackgroundTaskManagerUtil.getBackgroundTasks(
                    sourceGroupId, LayoutStagingBackgroundTaskExecutor.class.getName(),
                    BackgroundTaskConstants.STATUS_QUEUED);

            for (BackgroundTask queuedBackgroundTask : queuedBackgroundTasks) {

                BackgroundTaskManagerUtil.amendBackgroundTask(queuedBackgroundTask.getBackgroundTaskId(), null,
                        BackgroundTaskConstants.STATUS_CANCELLED, new ServiceContext());
            }
        }

        deleteTempLarOnFailure(file);

        throw new SystemException(t);
    }

    deleteTempLarOnSuccess(file);

    return processMissingReferences(backgroundTask.getBackgroundTaskId(), missingReferences);
}

From source file:com.liferay.exportimport.staging.LayoutStagingImpl.java

License:Open Source License

@Override
public boolean isBranchingLayoutSet(Group group, boolean privateLayout) {
    boolean isStagingGroup = false;

    if (group.isStagingGroup() && !group.isStagedRemotely()) {
        isStagingGroup = true;//from w ww. j a va2 s.  co m

        group = group.getLiveGroup();
    }

    UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties();

    if (typeSettingsProperties.isEmpty()) {
        return false;
    }

    boolean branchingEnabled = false;

    if (privateLayout) {
        branchingEnabled = GetterUtil.getBoolean(typeSettingsProperties.getProperty("branchingPrivate"));
    } else {
        branchingEnabled = GetterUtil.getBoolean(typeSettingsProperties.getProperty("branchingPublic"));
    }

    if (!branchingEnabled || !group.isStaged() || (!group.isStagedRemotely() && !isStagingGroup)) {

        return false;
    }

    Group stagingGroup = group;

    if (isStagingGroup) {
        stagingGroup = group.getStagingGroup();
    }

    try {
        _layoutSetBranchLocalService.getMasterLayoutSetBranch(stagingGroup.getGroupId(), privateLayout);

        return true;
    } catch (PortalException pe) {

        // LPS-52675

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

        return false;
    }
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public Group getPermissionStagingGroup(Group group) {
    if (group == null) {
        return null;
    }/* w  w w  .j  a  va 2 s .c  o m*/

    Group stagingGroup = group;

    if (!group.isStagedRemotely() && group.hasStagingGroup()) {
        try {
            PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

            long scopeGroupId = stagingGroup.getGroupId();

            boolean hasManageStagingPermission = GroupPermissionUtil.contains(permissionChecker, scopeGroupId,
                    ActionKeys.MANAGE_STAGING);
            boolean hasPublishStagingPermission = GroupPermissionUtil.contains(permissionChecker, scopeGroupId,
                    ActionKeys.PUBLISH_STAGING);
            boolean hasViewStagingPermission = GroupPermissionUtil.contains(permissionChecker, scopeGroupId,
                    ActionKeys.VIEW_STAGING);

            if (hasManageStagingPermission || hasPublishStagingPermission || hasViewStagingPermission) {

                stagingGroup = group.getStagingGroup();
            }
        } catch (Exception e) {
        }
    }

    return stagingGroup;
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public long[] getStagingAndLiveGroupIds(long groupId) throws PortalException {

    Group group = _groupLocalService.fetchGroup(groupId);

    if (group == null) {
        return new long[] { groupId, 0L };
    }/*from  ww w  .  j  a v  a 2  s  .  c o  m*/

    Group stagingGroup = group.getStagingGroup();

    if (stagingGroup != null) {
        return new long[] { stagingGroup.getGroupId(), groupId };
    }

    Group liveGroup = group.getLiveGroup();

    if (liveGroup != null) {
        return new long[] { groupId, liveGroup.getGroupId() };
    }

    return new long[] { groupId, 0L };
}