使用钩子在Liferay中将站点添加到组织

时间:2012-09-17 16:56:40

标签: liferay

我正在尝试使用hook创建组织并为组织实体添加侦听器时为组织创建站点。

我使用GroupLocalServiceUtil创建了网站,并在数据库中设置了siteName = String.valueOf(org.getOrganizationId()) + "LFR_ORGANIZATION" + org.getName()

此外,我设置了classNameclassPK,就像在liferay中创建网站组织时一样,但没有任何反应。网站创建成功,但与本组织无关。

UPD。 Liferay 6.1 GA1

public Group addSite(Organization org) throws PortalException, SystemException
{
    ServiceContext serviceContext = new ServiceContext();
    String siteName = String.valueOf(org.getOrganizationId()) + "LFR_ORGANIZATION" + org.getName();

    Group newSite = GroupLocalServiceUtil.addGroup(
            getDefaultUserId(),
            "com.liferay.portal.model.Organization",    // Class Name
            org.getOrganizationId(),                    // Class PK
            siteName ,                                  // Name
            "",                                         // Description
            GroupConstants.TYPE_SITE_PRIVATE,           // Type
            org.getTreePath(),                          // Friendly URL
            true,                                       // Site
            true,                                       // Active
            serviceContext);

    OrganizationUtil.addGroup(org.getPrimaryKey(), newSite);

    return newSite;
}

如何以编程方式创建此类组织网站?

1 个答案:

答案 0 :(得分:2)

在Liferay 6.1中,似乎在创建组织时,已经有一个支持组。根据您传递的boolean site参数,该组可能不可见:

OrganiztionLocalServiceUtil.addOrganization(
    long userId, long parentOrganizationId, String name, String type,
    boolean recursable, long regionId, long countryId, int statusId,
    String comments, boolean site, ServiceContext serviceContext)

要使该网站对网页可见,只需致电:

OrganiztionLocalServiceUtil.updateOrganization(
    long companyId, long organizationId, long parentOrganizationId,
    String name, String type, boolean recursable, long regionId,
    long countryId, int statusId, String comments, boolean site,
    ServiceContext serviceContext)

site参数设置为true

相关问题