花了三天,终于把sign-up模块做好了,要取代原有的createacount真不是件容易的事情。Liferay本身的用户管理已经 很完善,不使用原有的而重新编码真的很浪费,但需求中用户资料与Liferay提供的有很大出入,而且很多字段需要加密,只能勉强去重做了。
下载Liferay 专业版直接运行,并没有createacount,但在Liferay官方网站是可以注册的,对于这样成熟的平台不可能没有考虑到sign up,不幸的是无论是其官方论坛还是google里都能搜到相关的资料。研究了其
login.jsp 页面,发现其中有一条判断语句控制createacount的可见性,去除判断直接让其显示并不能解决问题(页面报错)。找了很久,终于找到了设置的地 方。在Admin→Authentication可进行设置,此处还可以设置用邮件或者ID进行登录。顺便说一下其他几个页面各有什么作用:
Default Communities and Roles:设置默认注册用户的权限和所属Community
Reserved Users:设置系统保留的email和id,新注册用户将不可以使用
Mail Host Names:尚未研究清楚,据我所知,Mail Host是在ROOT.xml或server.xml中进行配置的
Emails:此处配置邮件模版及参数,Liferay向用户发送邮件时需要使用到这些模版及参数
Liferay在注册时对以下表进行操作:
User_,User_Roles,Contact_,Group_,LayoutSet,Permission_,Users_Permissions
如果重新对这些表进行操作,任务量可想而知,而且实现也比较困难,我采用了对其原有注册类 进行重新编码表示的方法,主要涉及到以下几个类:com.liferay.portal.service.impl.ImageLocalUtil、 PrincipalBean、PrincipalSessionBean、UserLocalServiceImpl、UserServiceImpl; com.liferay.portal.service.spring.UserLocalService、 UserLocalServiceFactory、UserLocalServiceUtil、UserService、 UserServiceFactory、UserServiceUtil。一般情况下只需对UserLocalServiceImpl进行重新编码,加入 你所需要的代码。并增加xxx-spring-professional.xml配置文件,如下:
<?xml version="1.0"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" " http://www.springframework.org/dtd/spring-beans.dtd ">
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" " http://www.springframework.org/dtd/spring-beans.dtd ">
<beans>
<bean id="com.liferay.portal.service.spring.UserLocalService.professional" class="com.liferay.portal.service.impl.UserLocalServiceImpl" lazy-init="true" />
<bean id="com.liferay.portal.service.spring.UserLocalService.transaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">
<property name="transactionManager">
<ref bean="liferayTransactionManager" />
</property>
<property name="target">
<ref bean="com.liferay.portal.service.spring.UserLocalService.professional" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="com.liferay.portal.service.spring.UserLocalServiceFactory" class="com.liferay.portal.service.spring.UserLocalServiceFactory" lazy-init="true">
<property name="service">
<ref bean="com.liferay.portal.service.spring.UserLocalService.transaction" />
</property>
</bean>
<bean id="com.liferay.portal.service.spring.UserService.professional" class="com.liferay.portal.service.impl.UserServiceImpl" lazy-init="true" />
<bean id="com.liferay.portal.service.spring.UserService.transaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">
<property name="transactionManager">
<ref bean="liferayTransactionManager" />
</property>
<property name="target">
<ref bean="com.liferay.portal.service.spring.UserService.professional" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="com.liferay.portal.service.spring.UserServiceFactory" class="com.liferay.portal.service.spring.UserServiceFactory" lazy-init="true">
<property name="service">
<ref bean="com.liferay.portal.service.spring.UserService.transaction" />
</property>
</bean>
</beans>
<bean id="com.liferay.portal.service.spring.UserLocalService.professional" class="com.liferay.portal.service.impl.UserLocalServiceImpl" lazy-init="true" />
<bean id="com.liferay.portal.service.spring.UserLocalService.transaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">
<property name="transactionManager">
<ref bean="liferayTransactionManager" />
</property>
<property name="target">
<ref bean="com.liferay.portal.service.spring.UserLocalService.professional" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="com.liferay.portal.service.spring.UserLocalServiceFactory" class="com.liferay.portal.service.spring.UserLocalServiceFactory" lazy-init="true">
<property name="service">
<ref bean="com.liferay.portal.service.spring.UserLocalService.transaction" />
</property>
</bean>
<bean id="com.liferay.portal.service.spring.UserService.professional" class="com.liferay.portal.service.impl.UserServiceImpl" lazy-init="true" />
<bean id="com.liferay.portal.service.spring.UserService.transaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">
<property name="transactionManager">
<ref bean="liferayTransactionManager" />
</property>
<property name="target">
<ref bean="com.liferay.portal.service.spring.UserService.professional" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="com.liferay.portal.service.spring.UserServiceFactory" class="com.liferay.portal.service.spring.UserServiceFactory" lazy-init="true">
<property name="service">
<ref bean="com.liferay.portal.service.spring.UserService.transaction" />
</property>
</bean>
</beans>
然后在portal-ext.properties中设置spring.configs=xxx-spring-professional.xml
现在基本的操作就完成了,剩下的就是根据业务逻辑去编写sign up代码了。