当前位置: 首页>>代码示例>>Java>>正文


Java Layout.getLayoutType方法代码示例

本文整理汇总了Java中com.liferay.portal.model.Layout.getLayoutType方法的典型用法代码示例。如果您正苦于以下问题:Java Layout.getLayoutType方法的具体用法?Java Layout.getLayoutType怎么用?Java Layout.getLayoutType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.liferay.portal.model.Layout的用法示例。


在下文中一共展示了Layout.getLayoutType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addPortletToPage

import com.liferay.portal.model.Layout; //导入方法依赖的package包/类
public static String addPortletToPage(Layout layout, String portletId, E_ContextPath path, long userId) {
	String result = null;
	try {
		LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
		
		// count all portlets currently registered for this column
		List<Portlet> portlets = layoutTypePortlet.getAllPortlets(path.getColumnId());
		int colSize = portlets != null ? portlets.size() : 0;
		// add new portlet at the very end
		result = layoutTypePortlet.addPortletId(userId, portletId, path.getColumnId(), colSize, false);
		
		// update the layout
		LayoutLocalServiceUtil.updateLayout(layout.getGroupId(),
                   layout.isPrivateLayout(),
                   layout.getLayoutId(),
                   layout.getTypeSettings());
		
	} catch (Throwable t) {
		m_objLog.warn(t);
	}
	return result;
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:23,代码来源:ParticityInitializer.java

示例2: setupPage

import com.liferay.portal.model.Layout; //导入方法依赖的package包/类
protected void setupPage(long userId, long groupId, PortalPage portalPage, boolean privateLayout) throws Exception {
	String portalPageName = portalPage.getName();
	String[] portletIds = portalPage.getPortletIds();
	Layout portalPageLayout = getPortalPageLayout(userId, groupId, portalPageName, privateLayout);
	LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) portalPageLayout.getLayoutType();

	layoutTypePortlet.setLayoutTemplateId(userId, "2_columns_i", false);

	int columnNumber = 1;

	for (String portletId : portletIds) {

		if (portletId.endsWith("_INSTANCE_")) {
			portletId = portletId + "ABCD";
		}

		addPortlet(layoutTypePortlet, userId, columnNumber, portletId);
		columnNumber++;
	}

	LayoutLocalServiceUtil.updateLayout(portalPageLayout);

	logger.info("Setting up page name=[" + portalPageName + "]");
}
 
开发者ID:ngriffin7a,项目名称:portletbox,代码行数:25,代码来源:TestSetupAction.java

示例3: initLayout

import com.liferay.portal.model.Layout; //导入方法依赖的package包/类
public static Layout initLayout(long companyId, long adminId, long groupId, E_ContextPath path) {
	Layout site = getLayout(groupId, path.getPath());
	try {
		if (site == null) {
			site = createLayout(adminId, companyId, groupId, path, null);
		} else {
			// clear portlets
			clearPage(site, path, null);
		}
		Theme theme = getTheme(companyId, path.getThemeId());
		if (theme != null) {
			site.setThemeId(path.getThemeId());
			site = LayoutLocalServiceUtil.updateLookAndFeel(site.getGroupId(),
					false, site.getLayoutId(), path.getThemeId(), "01", "", false);
		} else
			m_objLog.warn("Did not find theme "+path.getThemeId()+"!");
           LayoutTemplate template = getLayoutTemplate(path.getTemplateId());
		
		LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) site.getLayoutType();
		if (template != null) {
			layoutTypePortlet.setLayoutTemplateId(0, path.getTemplateId(), false);
		} else
			m_objLog.warn("Did not find layout template "+path.getTemplateId()+"!");
		updatePermissions(site, path);
	} catch (Throwable t) {
		m_objLog.error(t);
	}
	return site;
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:30,代码来源:ParticityInitializer.java

示例4: checkArticleOnLayout

import com.liferay.portal.model.Layout; //导入方法依赖的package包/类
public static boolean checkArticleOnLayout(Layout layout, String articleId, String columnId, long companyId) {
	boolean result = false;
	
	try {

		long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
		int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
		
		LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

		List<Portlet> portlets = layoutTypePortlet.getAllPortlets(columnId);
		if (portlets != null) {
			for (Portlet portlet: portlets) {
				//m_objLog.debug("Found portlet "+portlet.getPortletId()+" =? "+PortletKeys.JOURNAL_CONTENT);
				if (portlet.getPortletId().startsWith(PortletKeys.JOURNAL_CONTENT+"_INSTANCE")) {
					PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId,
			                ownerId,
			                ownerType,
			                layout.getPlid(),
			                portlet.getPortletId());
					String jArticleId = prefs.getValue("articleId", "");
					if (jArticleId.equals(articleId)) {
						result = true;
						break;
					}
				}
			}
		}
	} catch (Throwable t) {
		m_objLog.warn(t);
	}
	return result;
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:34,代码来源:ParticityInitializer.java

示例5: test

import com.liferay.portal.model.Layout; //导入方法依赖的package包/类
public static void test() {
	try {
		if (globalCompanyId == -1)
			initGlobals();

		Layout layout = getLayout(globalGroupId, E_ContextPath.HOME.getPath());
		
		LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

		List<Portlet> portlets = layoutTypePortlet.getAllPortlets();
		if (portlets != null) {
			for (Portlet portlet: portlets) {
				m_objLog.debug("Found portlet "+portlet.getPortletId()+" =? "+PortletKeys.JOURNAL_CONTENT);
				if (portlet.getPortletId().startsWith(E_SampleContent.FRONTEND_HEADER.getDataPath())) {

					long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
					int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
			
					PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(globalCompanyId,
			                ownerId,
			                ownerType,
			                layout.getPlid(),
			                portlet.getPortletId());
					
					if (prefs != null) {
						Enumeration<String> names = prefs.getNames();
						while (names.hasMoreElements()) {
							String name = names.nextElement();
							m_objLog.debug("Got preference "+name+"="+prefs.getValue(name, "N/A"));
						}
					} else {
						m_objLog.debug("Could not extract portlet prefs!");
					}
				}
			}
		}
	} catch (Throwable t) {
		m_objLog.error(t);
	}
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:41,代码来源:ParticityInitializer.java

示例6: afterPropertiesSet

import com.liferay.portal.model.Layout; //导入方法依赖的package包/类
public void afterPropertiesSet() throws Exception {
	User user = UserLocalServiceUtil.getDefaultUser(companyId);

	userId = user.getUserId();

	Group group = null;

	if (targetClassName.equals(LayoutSetPrototype.class.getName())) {
		LayoutSetPrototype layoutSetPrototype = getLayoutSetPrototype(
			companyId, targetValue);

		if (layoutSetPrototype != null) {
			existing = true;
		}
		else {
			layoutSetPrototype =
				LayoutSetPrototypeLocalServiceUtil.addLayoutSetPrototype(
					userId, companyId, getTargetValueMap(),
					StringPool.BLANK, true, true, new ServiceContext());
		}

		group = layoutSetPrototype.getGroup();

		targetClassPK = layoutSetPrototype.getLayoutSetPrototypeId();
	}
	else if (targetClassName.equals(Group.class.getName())) {
		if (targetValue.equals(GroupConstants.GUEST)) {
			group = GroupLocalServiceUtil.getGroup(
				companyId, GroupConstants.GUEST);

			List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(
				group.getGroupId(), false,
				LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, false, 0, 1);

			if (!layouts.isEmpty()) {
				Layout layout = layouts.get(0);

				LayoutTypePortlet layoutTypePortlet =
					(LayoutTypePortlet)layout.getLayoutType();

				List<String> portletIds = layoutTypePortlet.getPortletIds();

				if (portletIds.size() != 2) {
					existing = true;
				}

				for (String portletId : portletIds) {
					if (!portletId.equals("47") &&
						!portletId.equals("58")) {

						existing = true;
					}
				}
			}
		}
		else {
			group = GroupLocalServiceUtil.fetchGroup(
				companyId, targetValue);

			if (group != null) {
				existing = true;
			}
			else {
				group = GroupLocalServiceUtil.addGroup(
					userId, GroupConstants.DEFAULT_PARENT_GROUP_ID,
					StringPool.BLANK,
					GroupConstants.DEFAULT_PARENT_GROUP_ID,
					GroupConstants.DEFAULT_LIVE_GROUP_ID, targetValue,
					StringPool.BLANK, GroupConstants.TYPE_SITE_OPEN, true,
					GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, null,
					true, true, new ServiceContext());
			}
		}

		targetClassPK = group.getGroupId();
	}

	if (group != null) {
		groupId = group.getGroupId();
	}
}
 
开发者ID:rivetlogic,项目名称:liferay-document-and-media-treeview,代码行数:82,代码来源:BaseImporter.java

示例7: createLayout

import com.liferay.portal.model.Layout; //导入方法依赖的package包/类
public static Layout createLayout(long adminId, long companyId, long groupId, E_ContextPath path, String actualPath) {
	Layout result = null;
	
	boolean privateLayout = false;
	String description = null;
	String type = path.getType();
	long parentLayoutId = path.isHidden() ?  homeLayoutId : LayoutConstants.DEFAULT_PARENT_LAYOUT_ID;
	ServiceContext ctx = new ServiceContext();
	if (actualPath == null)
		actualPath = path.getPath();
	
	try {
		
		result = LayoutLocalServiceUtil.addLayout(adminId, groupId,
				privateLayout, parentLayoutId, path.getName(), path.getTitle(), description,
				type, path.isHidden(), actualPath, ctx);
		

		// layout.setLayoutPrototypeLinkEnabled(false);
		
		if (!type.equals(LayoutConstants.TYPE_URL)) {

			Theme theme = getTheme(companyId, path.getThemeId());
			if (theme != null) {
				result.setThemeId(path.getThemeId());
				result = LayoutLocalServiceUtil.updateLookAndFeel(groupId,
						false, result.getLayoutId(), path.getThemeId(), "01", "", false);
			} else
				m_objLog.warn("Did not find theme: " + path.getThemeId() + " for url "
						+ path.getPath());

			LayoutTemplate template = getLayoutTemplate(path.getTemplateId());
			
			LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) result
					.getLayoutType();
			if (template != null) {
				layoutTypePortlet.setLayoutTemplateId(0, path.getTemplateId(), false);
				m_objLog.debug("Set layout template: "
						+ template.getLayoutTemplateId() + " for url "
						+ path.getPath());
			} else
				m_objLog.warn("Did not find layout template: " + path.getTemplateId()
						+ " for url " + path.getPath());

		} else {
			// set the value of the "link to page"
			UnicodeProperties props = result.getTypeSettingsProperties();
			props.put( "url", path.getTitle() );
			result.setTypeSettingsProperties( props );
			LayoutLocalServiceUtil.updateLayout( result ); // 
		}
		
		m_objLog.debug("Added layout for url " + actualPath + ", group: "
				+ groupId + ", company: " + companyId + ", user: "
				+ adminId);

		updatePermissions(result, path);
		
	} catch (Throwable t) {
		m_objLog.error(t);
	}
	return result;
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:64,代码来源:ParticityInitializer.java

示例8: addLayoutColumnPortlet

import com.liferay.portal.model.Layout; //导入方法依赖的package包/类
protected void addLayoutColumnPortlet(
		Layout layout, String columnId, JSONObject portletJSONObject)
	throws Exception {

	LayoutTypePortlet layoutTypePortlet =
		(LayoutTypePortlet)layout.getLayoutType();

	String rootPortletId = portletJSONObject.getString("portletId");

	if (Validator.isNull(rootPortletId)) {
		throw new ImporterException("portletId is not specified");
	}

	String portletId = layoutTypePortlet.addPortletId(
		userId, rootPortletId, columnId, -1, false);

	JSONObject portletPreferencesJSONObject =
		portletJSONObject.getJSONObject("portletPreferences");

	if ((portletPreferencesJSONObject == null) ||
		(portletPreferencesJSONObject.length() == 0)) {

		return;
	}

	PortletPreferences portletSetup =
		PortletPreferencesFactoryUtil.getLayoutPortletSetup(
			layout, portletId);

	Iterator<String> iterator = portletPreferencesJSONObject.keys();

	while (iterator.hasNext()) {
		String key = iterator.next();

		String value = portletPreferencesJSONObject.getString(key);

		if (rootPortletId.equals(PortletKeys.JOURNAL_CONTENT) &&
			key.equals("articleId")) {

			value = getJournalId(value);
		}

		portletSetup.setValue(key, value);
	}

	portletSetup.store();

	if (rootPortletId.equals(PortletKeys.NESTED_PORTLETS)) {
		JSONArray columnsJSONArray =
			portletPreferencesJSONObject.getJSONArray("columns");

		StringBundler sb = new StringBundler(4);

		sb.append(StringPool.UNDERLINE);
		sb.append(portletId);
		sb.append(StringPool.DOUBLE_UNDERLINE);
		sb.append(LayoutTypePortletConstants.COLUMN_PREFIX);

		addLayoutColumns(layout, sb.toString(), columnsJSONArray);
	}
}
 
开发者ID:rivetlogic,项目名称:liferay-evernote,代码行数:62,代码来源:FileSystemImporter.java


注:本文中的com.liferay.portal.model.Layout.getLayoutType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。