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

标签 java ldap liferay liferay-6

我需要重写 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/

    相关文章:

    encryption - Jackrabbit 中的密码加密

    java - 如何保存上传的文件

    c# - 使用 C# 目录服务连接到 LDAP 时正确处理资源

    search - ldap 返回子树和一级,但不返回基础

    Spring LDAP Context.REFERRAL 遵循

    java - Liferay 中的 Oracle 自定义 sql

    java - 无法在Java中使用appium单击硬件菜单按钮

    java - 如何获取 Windows 文件详细信息?

    从线程的队列中获取时出现 Java 'NoSuchElementException'

    tomcat - 将tomcat session 超时与已部署的应用程序同步