gpt4 book ai didi

java - Liferay 通过 ext 插件对源代码进行的更改没有发生

转载 作者:行者123 更新时间:2023-12-02 12:18:43 27 4
gpt4 key购买 nike

我需要重写 portalLDAPImporterImpl.java addUser() 方法,以便在用户从 LDAP 导入并添加到 Liferay 后执行某些操作。我按照以下步骤操作(Eclipse 环境):

  1. 已创建Ext插件项目名称customLdap;
  2. docroot/WEB-INF/ext-impl/src中,我创建了一个包名称com.liferay.portal.security.ldap
  3. 在那里,我创建了扩展 portalLDAPImporterImpl.javaCustomPortalLDAPImporterImpl.java 类,并重写了 addUser 方法

代码摘录:

    @Override

protected User addUser(long companyId, LDAPUser ldapUser, String password)
throws Exception {

if (_log.isDebugEnabled()) {
_log.debug("Adding user " + ldapUser.getEmailAddress());
}

boolean autoPassword = ldapUser.isAutoPassword();

if (!PropsValues.LDAP_IMPORT_USER_PASSWORD_ENABLED) {
autoPassword = PropsValues.LDAP_IMPORT_USER_PASSWORD_AUTOGENERATED
&& !PropsValues.AUTH_PIPELINE_ENABLE_LIFERAY_CHECK;

if (!autoPassword) {
String defaultPassword = PropsValues.LDAP_IMPORT_USER_PASSWORD_DEFAULT;

if (StringUtil.equalsIgnoreCase(defaultPassword,
_USER_PASSWORD_SCREEN_NAME)) {

defaultPassword = ldapUser.getScreenName();
}

password = defaultPassword;
}
}

Calendar birthdayCal = CalendarFactoryUtil.getCalendar();

birthdayCal.setTime(ldapUser.getBirthday());

int birthdayMonth = birthdayCal.get(Calendar.MONTH);
int birthdayDay = birthdayCal.get(Calendar.DAY_OF_MONTH);
int birthdayYear = birthdayCal.get(Calendar.YEAR);

User user = UserLocalServiceUtil.addUser(ldapUser.getCreatorUserId(),
companyId, autoPassword, password, password,
ldapUser.isAutoScreenName(), ldapUser.getScreenName(),
ldapUser.getEmailAddress(), 0, StringPool.BLANK,
ldapUser.getLocale(), ldapUser.getFirstName(),
ldapUser.getMiddleName(), ldapUser.getLastName(), 0, 0,
ldapUser.isMale(), birthdayMonth, birthdayDay, birthdayYear,
StringPool.BLANK, ldapUser.getGroupIds(),
ldapUser.getOrganizationIds(), ldapUser.getRoleIds(),
ldapUser.getUserGroupIds(), ldapUser.isSendEmail(),
ldapUser.getServiceContext());
_log.info("-----------------------------------------User||||Added----------------------------------------");

if (ldapUser.isUpdatePortrait()) {
byte[] portraitBytes = ldapUser.getPortraitBytes();

if (ArrayUtil.isNotEmpty(portraitBytes)) {
user = UserLocalServiceUtil.updatePortrait(user.getUserId(),
portraitBytes);
}
}

return user;
}
  • docroot/WEB-INF/ext-impl/src中创建了名为META-INF的文件夹

  • META-INF 中创建了一个名为 ext-spring.xml 的文件,其中包含以下代码:

  • enter image description here

  • 构建并发布我的插件
  • 从 dist 文件夹复制 customLdap-ext.war 文件并将其粘贴到我的 Tomcat 部署文件夹中
  • 启动我的服务器,加载旧配置,从 ldap 导入新用户时不打印日志
  • 我这样做哪里出错了?

    注意:我使用的是liferay 6.2.0.1 CE-GA6

    最佳答案

    我还重写了PortalLDAPImporterImpl.java。您不必定义 ext-spring.xml。只需将原始类复制到 com.liferay.portal.security.ldap 包中的 docroot/WEB-INF/ext-impl/src 并进行更改即可。不要创建 CustomPortalLDAPImporterImpl.java

    关于java - Liferay 通过 ext 插件对源代码进行的更改没有发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45962795/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com