0

当使用钩子创建组织并将侦听器添加到组织实体时,我正在尝试为组织创建站点。

我使用数据库创建站点GroupLocalServiceUtil并进行设置siteName = String.valueOf(org.getOrganizationId()) + "LFR_ORGANIZATION" + org.getName()

当您在liferay中创建站点到组织时,我已经设置className并喜欢它,但没有任何反应。classPK站点创建成功,但未与组织连接。

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;
}

如何以编程方式创建这样的组织站点?

4

1 回答 1

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.

于 2012-09-17T23:31:59.603 回答