Hi Raminder, we've been working on extending the User for our internal
implementation. It's still in the early stages but here is what I've done so
far (all code is done in our overlay):
1) Create a Custom user:
package org.custom.portal.model;
@Entity
public class CustomUser extends org.apache.rave.model.User {
@Transient
private String employeeNumber;
@Transient
private String jobTitle;
@Transient
private String building;
...
// other custom user attributes
}
Our custom fields are marked Transient as they are populated from a read-only
data source (LDAP) and we don't plan on allowing updates to them via Rave.
2) Create a new CustomUserRepository interface:
public interface CustomUserRepository {
CustomUser getByEmployeeNumber(String employeeNumber);
// ... other custom function signatures
}
3) Create a new DefaultCustomUserRepository class with "userRepository" as the
bean name that is marked as @Primary to override the default Rave
userRepository implemenation (DefaultUserRepository). This custom class will
get injected into any Spring Bean that needs a "userRepository" like
UserService.
@Repository(value="userRepository")
@Primary
@Transactional
public class DefaultCustomUserRepository extends JpaUserRepository implements
CustomUserRepository {
@Override
public CustomUser getByEmployeeNumber(String employeeNumber) {
...
}
// custom code that fetches the new user data fields from our LDAP server
private CustomUser getCustomUserFromLDAP(String employeeNumber) {
...
}
}
4) Overlay core-applicationContext.xml with our version that includes component
scans of our custom packages:
...
<!-- component scan custom code -->
<context:component-scan base-package="org.custom.portal.repository"/>
...
5) Overlay applicationContext.xml to reference our core-applicationContext.xml
file:
...
<import
resource="classpath*:org/custom/portal/core-applicationContext.xml"/>
<import resource="classpath*:org/apache/rave/web-applicationContext.xml"/>
<import
resource="classpath*:org/apache/rave/opensocial-provider-applicationContext.xml"/>
<import
resource="classpath*:org/apache/rave/w3c-provider-applicationContext.xml"/>
...
Again we are still in the early stages of this work so things may change over
time but this should give you enough of a starting point.
Tony
>-----Original Message-----
>From: Raminderjeet Singh [mailto:[email protected]]
>Sent: Thursday, February 16, 2012 3:30 PM
>To: [email protected]
>Subject: Extend Person model as Rave-Extension
>
>Hi Devs,
>
>I am trying to extend the person object to add new data fields using rave-
>vanilla-extension. War overlay works fine for new services like
>(CustomUserService) and web components but it does not overlay
>dependency artifact jars. I tried to overlay rave-core jar only in a separate
>project but was not successful to extend user model. I can add my code to
>rave-core itself and it works well. Any ideas how can i make this work from
>rave-extensions? I think this use case will be true for any custom portals
>based on Rave. I added my sample code in rave-vanilla-extension sandbox. I
>created RAVE-447 for this also.
>
>Thanks
>Raminder