List of usage examples for com.liferay.portal.kernel.model GroupConstants DEFAULT
String DEFAULT
To view the source code for com.liferay.portal.kernel.model GroupConstants DEFAULT.
Click Source Link
From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java
License:Open Source License
@Override public long getGroupIdFromScopeId(String scopeId, long siteGroupId, boolean privateLayout) throws PortalException { if (scopeId.startsWith(SCOPE_ID_CHILD_GROUP_PREFIX)) { String scopeIdSuffix = scopeId.substring(SCOPE_ID_CHILD_GROUP_PREFIX.length()); long childGroupId = GetterUtil.getLong(scopeIdSuffix); Group childGroup = _groupLocalService.getGroup(childGroupId); if (!childGroup.hasAncestor(siteGroupId)) { throw new PrincipalException(); }//from w ww .ja v a 2 s.c o m return childGroupId; } else if (scopeId.startsWith(SCOPE_ID_GROUP_PREFIX)) { String scopeIdSuffix = scopeId.substring(SCOPE_ID_GROUP_PREFIX.length()); if (scopeIdSuffix.equals(GroupConstants.DEFAULT)) { return siteGroupId; } long scopeGroupId = GetterUtil.getLong(scopeIdSuffix); Group scopeGroup = _groupLocalService.getGroup(scopeGroupId); return scopeGroup.getGroupId(); } else if (scopeId.startsWith(SCOPE_ID_LAYOUT_UUID_PREFIX)) { String layoutUuid = scopeId.substring(SCOPE_ID_LAYOUT_UUID_PREFIX.length()); Layout scopeIdLayout = _layoutLocalService.getLayoutByUuidAndGroupId(layoutUuid, siteGroupId, privateLayout); Group scopeIdGroup = _groupLocalService.checkScopeGroup(scopeIdLayout, PrincipalThreadLocal.getUserId()); return scopeIdGroup.getGroupId(); } else if (scopeId.startsWith(SCOPE_ID_LAYOUT_PREFIX)) { // Legacy portlet preferences String scopeIdSuffix = scopeId.substring(SCOPE_ID_LAYOUT_PREFIX.length()); long scopeIdLayoutId = GetterUtil.getLong(scopeIdSuffix); Layout scopeIdLayout = _layoutLocalService.getLayout(siteGroupId, privateLayout, scopeIdLayoutId); Group scopeIdGroup = scopeIdLayout.getScopeGroup(); return scopeIdGroup.getGroupId(); } else if (scopeId.startsWith(SCOPE_ID_PARENT_GROUP_PREFIX)) { String scopeIdSuffix = scopeId.substring(SCOPE_ID_PARENT_GROUP_PREFIX.length()); long parentGroupId = GetterUtil.getLong(scopeIdSuffix); Group parentGroup = _groupLocalService.getGroup(parentGroupId); if (!SitesUtil.isContentSharingWithChildrenEnabled(parentGroup)) { throw new PrincipalException(); } Group group = _groupLocalService.getGroup(siteGroupId); if (!group.hasAncestor(parentGroupId)) { throw new PrincipalException(); } return parentGroupId; } else { throw new IllegalArgumentException("Invalid scope ID " + scopeId); } }
From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java
License:Open Source License
@Override public String getScopeId(Group group, long scopeGroupId) { String key = null;/* w ww . jav a 2s. co m*/ if (group.isLayout()) { Layout layout = _layoutLocalService.fetchLayout(group.getClassPK()); key = SCOPE_ID_LAYOUT_UUID_PREFIX + layout.getUuid(); } else if (group.isLayoutPrototype() || (group.getGroupId() == scopeGroupId)) { key = SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT; } else { Group scopeGroup = _groupLocalService.fetchGroup(scopeGroupId); if (scopeGroup.hasAncestor(group.getGroupId()) && SitesUtil.isContentSharingWithChildrenEnabled(group)) { key = SCOPE_ID_PARENT_GROUP_PREFIX + group.getGroupId(); } else if (group.hasAncestor(scopeGroup.getGroupId())) { key = SCOPE_ID_CHILD_GROUP_PREFIX + group.getGroupId(); } else { key = SCOPE_ID_GROUP_PREFIX + group.getGroupId(); } } return key; }
From source file:com.liferay.asset.publisher.web.portlet.action.AssetPublisherConfigurationAction.java
License:Open Source License
protected void addScope(ActionRequest actionRequest, PortletPreferences preferences) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String[] scopeIds = preferences.getValues("scopeIds", new String[] { AssetPublisherUtil.SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT }); long groupId = ParamUtil.getLong(actionRequest, "groupId"); Group selectedGroup = groupLocalService.fetchGroup(groupId); String scopeId = AssetPublisherUtil.getScopeId(selectedGroup, themeDisplay.getScopeGroupId()); checkPermission(actionRequest, scopeId); if (!ArrayUtil.contains(scopeIds, scopeId)) { scopeIds = ArrayUtil.append(scopeIds, scopeId); }//from w ww. j a v a 2 s. c o m preferences.setValues("scopeIds", scopeIds); }
From source file:com.liferay.asset.publisher.web.portlet.action.AssetPublisherConfigurationAction.java
License:Open Source License
protected void removeScope(ActionRequest actionRequest, PortletPreferences preferences) throws Exception { String[] scopeIds = preferences.getValues("scopeIds", new String[] { AssetPublisherUtil.SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT }); String scopeId = ParamUtil.getString(actionRequest, "scopeId"); scopeIds = ArrayUtil.remove(scopeIds, scopeId); if (scopeId.startsWith(AssetPublisherUtil.SCOPE_ID_PARENT_GROUP_PREFIX)) { scopeId = scopeId.substring("Parent".length()); scopeIds = ArrayUtil.remove(scopeIds, scopeId); }/*from www. j a v a 2 s. c o m*/ preferences.setValues("scopeIds", scopeIds); }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
public static long getGroupIdFromScopeId(String scopeId, long siteGroupId, boolean privateLayout) throws PortalException { if (scopeId.startsWith(SCOPE_ID_CHILD_GROUP_PREFIX)) { String scopeIdSuffix = scopeId.substring(SCOPE_ID_CHILD_GROUP_PREFIX.length()); long childGroupId = GetterUtil.getLong(scopeIdSuffix); Group childGroup = _groupLocalService.getGroup(childGroupId); if (!childGroup.hasAncestor(siteGroupId)) { throw new PrincipalException(); }// w w w . j a v a 2s.c o m return childGroupId; } else if (scopeId.startsWith(SCOPE_ID_GROUP_PREFIX)) { String scopeIdSuffix = scopeId.substring(SCOPE_ID_GROUP_PREFIX.length()); if (scopeIdSuffix.equals(GroupConstants.DEFAULT)) { return siteGroupId; } long scopeGroupId = GetterUtil.getLong(scopeIdSuffix); Group scopeGroup = _groupLocalService.getGroup(scopeGroupId); return scopeGroup.getGroupId(); } else if (scopeId.startsWith(SCOPE_ID_LAYOUT_UUID_PREFIX)) { String layoutUuid = scopeId.substring(SCOPE_ID_LAYOUT_UUID_PREFIX.length()); Layout scopeIdLayout = _layoutLocalService.getLayoutByUuidAndGroupId(layoutUuid, siteGroupId, privateLayout); Group scopeIdGroup = _groupLocalService.checkScopeGroup(scopeIdLayout, PrincipalThreadLocal.getUserId()); return scopeIdGroup.getGroupId(); } else if (scopeId.startsWith(SCOPE_ID_LAYOUT_PREFIX)) { // Legacy portlet preferences String scopeIdSuffix = scopeId.substring(SCOPE_ID_LAYOUT_PREFIX.length()); long scopeIdLayoutId = GetterUtil.getLong(scopeIdSuffix); Layout scopeIdLayout = _layoutLocalService.getLayout(siteGroupId, privateLayout, scopeIdLayoutId); Group scopeIdGroup = scopeIdLayout.getScopeGroup(); return scopeIdGroup.getGroupId(); } else if (scopeId.startsWith(SCOPE_ID_PARENT_GROUP_PREFIX)) { String scopeIdSuffix = scopeId.substring(SCOPE_ID_PARENT_GROUP_PREFIX.length()); long parentGroupId = GetterUtil.getLong(scopeIdSuffix); Group parentGroup = _groupLocalService.getGroup(parentGroupId); if (!SitesUtil.isContentSharingWithChildrenEnabled(parentGroup)) { throw new PrincipalException(); } Group group = _groupLocalService.getGroup(siteGroupId); if (!group.hasAncestor(parentGroupId)) { throw new PrincipalException(); } return parentGroupId; } else { throw new IllegalArgumentException("Invalid scope ID " + scopeId); } }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
public static String getScopeId(Group group, long scopeGroupId) { String key = null;/*from ww w .j a v a 2s. co m*/ if (group.isLayout()) { Layout layout = _layoutLocalService.fetchLayout(group.getClassPK()); key = SCOPE_ID_LAYOUT_UUID_PREFIX + layout.getUuid(); } else if (group.isLayoutPrototype() || (group.getGroupId() == scopeGroupId)) { key = SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT; } else { Group scopeGroup = _groupLocalService.fetchGroup(scopeGroupId); if (scopeGroup.hasAncestor(group.getGroupId()) && SitesUtil.isContentSharingWithChildrenEnabled(group)) { key = SCOPE_ID_PARENT_GROUP_PREFIX + group.getGroupId(); } else if (group.hasAncestor(scopeGroup.getGroupId())) { key = SCOPE_ID_CHILD_GROUP_PREFIX + group.getGroupId(); } else { key = SCOPE_ID_GROUP_PREFIX + group.getGroupId(); } } return key; }