Liferay 在哪里可以找到此示例代码的SocialDriverConstants类?
这里我有一个以编程方式添加用户的代码。在代码中,第5行和第6行有Liferay 在哪里可以找到此示例代码的SocialDriverConstants类?,liferay,liferay-6,Liferay,Liferay 6,这里我有一个以编程方式添加用户的代码。在代码中,第5行和第6行有SocialDriverConstants,这是一个类,因此如果任何人有该类的代码,请共享。这段代码可以在詹姆斯·福克纳的Liferay博客中找到。代码是: public synchronized static User addUser(String firstName, long companyId, String themeId, boolean profil
SocialDriverConstants
,这是一个类,因此如果任何人有该类的代码,请共享。这段代码可以在詹姆斯·福克纳的Liferay博客中找到。代码是:
public synchronized static User addUser(String firstName, long companyId,
String themeId, boolean profileFlag)
throws Exception {
String lastName = getRndStr(SocialDriverConstants.LAST_NAMES);
String job = getRndStr(SocialDriverConstants.JOB_TITLES);
Group guestGroup = GroupLocalServiceUtil.getGroup(
companyId, GroupConstants.GUEST);
long[] groupIds;
try {
// see if there's a demo sales group, and add the user to the
// group if so
Group salesGroup = GroupLocalServiceUtil.getGroup(
companyId, "Sales");
groupIds = new long[]{guestGroup.getGroupId(),
salesGroup.getGroupId()};
} catch (Exception ex) {
groupIds = new long[]{guestGroup.getGroupId()};
}
ServiceContext serviceContext = new ServiceContext();
long[] roleIds;
try {
// see if we're using social office, and add SO's role to the new
// user if so
roleIds = new long[]{RoleLocalServiceUtil.getRole(companyId,
"Social Office User").getRoleId()};
serviceContext.setScopeGroupId(guestGroup.getGroupId());
} catch (Exception ignored) {
roleIds = new long[]{};
}
User user = UserLocalServiceUtil.addUser(UserLocalServiceUtil
.getDefaultUserId(companyId), companyId, false,
firstName,
firstName,
false, firstName.toLowerCase(), firstName.toLowerCase() +
"@liferay.com", 0, "",
LocaleUtil.getDefault(), firstName,
"", lastName, 0, 0, true, 8, 15, 1974, job, groupIds,
new long[]{}, roleIds, new long[]{},
false, serviceContext);
assignAddressTo(user);
setFirstLogin(firstName, user);
assignRandomFriends(user);
if (profileFlag) {
setupUserProfile(companyId, themeId, guestGroup, user);
}
return user;
}
在哪里可以找到该类?在上面发表评论(就像其他人已经做的那样,检查那里的评论)可能比在不相关的地方(例如stackoverflow)更有意义。与互联网上的其他地方相比,他更愿意阅读自己博客文章中的评论 这就是说,基于您发布的代码使用它的假设,即生成随机名称/职务,应该很容易找到该类的替换项。只需为它们生成任意内容,就可以满足使用它们的API(在本例中:
addUser
)