You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rave.apache.org by Raminderjeet Singh <ra...@gmail.com> on 2012/02/16 21:30:06 UTC

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

Re: Extend Person model as Rave-Extension

Posted by "anne-helene.turpin@renater.fr" <an...@renater.fr>.
Hi Tony and all,

I've got some questions about your work on extending the User model for 
your internal implementation. I try to do the same for the Person model 
and the person service SPI.
> 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.

What are you declare in the persistence file ?
If I declare the CutomPerson as an Entity in the class but not in the 
persistence file, I can't call declared named queries on it. So I had to 
annotate the CustomPerson model class with @MappedSuperclass and I had 
to declare the CustomPerson in the persistence file in order to use it. 
It's work.
>
> 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
>

I tried the same and it works for me if I'm declaring the 
PersonRepository in the service class but not with the 
CustomPersonRespository. But I can't call the custom method added in the 
CustomPersonRepository. If I declare a CustomPersonrepository in my 
CustomPersonService, I've got this deployment error :

    /org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'customPersonService' defined in URL
    [jar:file:....CustomPersonServiceImpl.class]: Unsatisfied dependency
    expressed through constructor argument with index 1 of type
    [fr.renater.opensocial.repository.impl.CustomPersonRepositoryImpl]:
    : No matching bean of type
    [fr.renater.opensocial.repository.impl.CustomPersonRepositoryImpl]
    found for dependency: expected at least 1 bean which qualifies as
    autowire candidate for this dependency. Dependency annotations: {};
    nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    matching bean of type
    [fr.renater.opensocial.repository.impl.CustomPersonRepositoryImpl]
    found for dependency: expected at least 1 bean which qualifies as
    autowire candidate for this dependency. Dependency annotations: {}/
    /..../
    /Caused by:
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    matching bean of type
    [fr.renater.opensocial.repository.impl.CustomPersonRepositoryImpl]
    found for dependency: expected at least 1 bean which qualifies as
    autowire candidate for this dependency. Dependency annotations: {}/


I don't understand. I create the custom repository class like this :

    /@Repository (value="personRepository")/
    /@Primary/
    /@Transactional/
    /public class CustomPersonRepositoryImpl extends JpaPersonRepository
    implements CustomPersonRepository{...}/

I include component scans of our custom package to the srping 
configuration file.

Which repository do you declare in your CustomUserService ? Can you 
share your experience ?

The original message was posted on the incubator developer mailing list. 
I'm sending a copy to the user mailing list, I think it could be 
interest some people.

Thanks
Anne-Hélène



-- 
Anne-Hélène TURPIN
Renater
Service Applicatif aux Utilisateurs
Tel : +33 2 23 23 71 42


Re: Extend Person model as Rave-Extension

Posted by Raminderjeet Singh <ra...@gmail.com>.
Thanks Tony,I will give a try to this. 


On Feb 17, 2012, at 10:30 AM, Carlucci, Tony wrote:

> Project Structure:
> 
> rave-custom/
>     pom.xml
>     custom-container/   # this has our overlay code for basically everything but shindig
>     custom-shindig/     # this has our overlay code for shindig only (like the shindig.properties, etc)
>     custom-portal/      # only has a pom.xml to deploy our custom war files via cargo
> 
> =============
> root pom.xml:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>    <modelVersion>4.0.0</modelVersion>
> 
>    <groupId>org.custom.portal</groupId>
>    <artifactId>custom-master</artifactId>
>    <name>custom Master Project</name>
>    <description>custom Master Project</description>
>    <packaging>pom</packaging>
>    <version>1.0.0</version>
> 
>    <parent>
>        <groupId>org.apache.rave</groupId>
>        <artifactId>rave-project</artifactId>
>        <version>0.9-incubating-SNAPSHOT</version>
>    </parent>
> 
>    <repositories>
>        <repository>
>            <id>apache-snapshots</id>
>            <name>Apache Software Foundation Snapshots</name>
>            <url>https://repository.apache.org/content/groups/snapshots</url>
>            <snapshots>
>                <enabled>true</enabled>
>            </snapshots>
>        </repository>
>    </repositories>
> 
>    <properties>
>        <rave.version>0.9-incubating-SNAPSHOT</rave.version>
>        <shindig.version>3.0.0-beta4</shindig.version>
>        <cargo.version>1.1.0</cargo.version>
>        <!-- if you want a remote debugging on a different a address override on command line with -Dcargo.debug.address=xxxx -->
>        <cargo.debug.address>8000</cargo.debug.address>
>        <!-- if you want to start remote debugging session suspended  override on command line with -Dcargo.debug.suspend=y -->
>        <cargo.debug.suspend>n</cargo.debug.suspend>
>        <javaagent/>
>    </properties>
> 
>    <dependencyManagement>
>        <dependencies>
>            <dependency>
>                <groupId>org.apache.rave</groupId>
>                <artifactId>rave-portal</artifactId>
>                <version>${rave.version}</version>
>                <type>war</type>
>            </dependency>
>            <dependency>
>                <groupId>org.apache.rave</groupId>
>                <artifactId>rave-shindig</artifactId>
>                <version>${rave.version}</version>
>                <type>war</type>
>            </dependency>
>        </dependencies>
>    </dependencyManagement>
> 
>    <modules>
>        <module>custom-container</module>
>        <module>custom-shindig</module>
>        <module>custom-portal</module>
>    </modules>
> </project>
> 
> =========================
> custom-container/pom.xml:
> 
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> 
>    <modelVersion>4.0.0</modelVersion>
> 
>    <parent>
>        <groupId>org.custom.portal</groupId>
>        <artifactId>custom-master</artifactId>
>        <version>1.0.0</version>
>    </parent>
> 
>    <groupId>org.custom.portal</groupId>
>    <artifactId>custom-container</artifactId>
>    <name>custom::Portal Container</name>
>    <description>custom Portal Container context</description>
>    <packaging>war</packaging>
> 
>    <dependencies>
>        <dependency>
>            <groupId>org.apache.rave</groupId>
>            <artifactId>rave-portal</artifactId>
>            <type>war</type>
>            <exclusions>
>                <exclusion>
>                    <groupId>org.apache.tomcat</groupId>
>                    <artifactId>jasper-el</artifactId>
>                </exclusion>
>                <exclusion>
>                    <groupId>org.apache.tomcat</groupId>
>                    <artifactId>el-api</artifactId>
>                </exclusion>
>                <exclusion>
>                    <groupId>org.glassfish.web</groupId>
>                    <artifactId>jstl-impl</artifactId>
>                </exclusion>
>            </exclusions>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.rave</groupId>
>            <artifactId>rave-core</artifactId>
>            <version>${rave.version}</version>
>            <type>jar</type>
>            <scope>provided</scope>            
>        </dependency>
>        <dependency>
>            <groupId>org.apache.rave</groupId>
>            <artifactId>rave-commons</artifactId>
>            <version>${rave.version}</version>
>            <type>jar</type>
>            <scope>provided</scope>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.rave</groupId>
>            <artifactId>rave-web</artifactId>
>            <version>${rave.version}</version>
>            <type>jar</type>
>            <scope>provided</scope>            
>        </dependency>
> 
>        <!-- Default database -->
>        <dependency>
>            <groupId>com.h2database</groupId>
>            <artifactId>h2</artifactId>
>        </dependency>
> 
>        <dependency>
>            <groupId>org.slf4j</groupId>
>            <artifactId>slf4j-log4j12</artifactId>
>            <scope>provided</scope>
>        </dependency>
> 
>        <!-- test dependencies -->
>        <dependency>
>            <groupId>org.easymock</groupId>
>            <artifactId>easymock</artifactId>
>            <scope>test</scope>
>        </dependency>
>        <dependency>
>            <groupId>org.springframework</groupId>
>            <artifactId>spring-test</artifactId>
>        </dependency>
> 
>    </dependencies>
> </project>
> 
>> -----Original Message-----
>> From: Raminderjeet Singh [mailto:raminderjsingh@gmail.com]
>> Sent: Friday, February 17, 2012 10:04 AM
>> To: rave-dev@incubator.apache.org
>> Subject: Re: Extend Person model as Rave-Extension
>> 
>> Thanks Tony,
>> 
>> I tried the same and it works well for me if i am doing all this in rave-core itself
>> but not as overlay. Can you share the overlay part of you project pom?
>> 
>> Raminder
>> 
>> On Feb 17, 2012, at 9:36 AM, Carlucci, Tony wrote:
>> 
>>> 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:raminderjsingh@gmail.com]
>>>> Sent: Thursday, February 16, 2012 3:30 PM
>>>> To: rave-dev@incubator.apache.org
>>>> 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
> 


Re: Extend Person model as Rave-Extension

Posted by Raminderjeet Singh <ra...@gmail.com>.
Hi Tony,

I see a problem here with the custom-container pom. If we are going to specify rave-core and rave-web provided then these jars are not going to be copied to generated war. Is the custom-container have all the rave core code in the project itself. 

Thanks
Raminder
On Feb 17, 2012, at 10:30 AM, Carlucci, Tony wrote:

> Project Structure:
> 
> rave-custom/
>     pom.xml
>     custom-container/   # this has our overlay code for basically everything but shindig
>     custom-shindig/     # this has our overlay code for shindig only (like the shindig.properties, etc)
>     custom-portal/      # only has a pom.xml to deploy our custom war files via cargo
> 
> =============
> root pom.xml:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>    <modelVersion>4.0.0</modelVersion>
> 
>    <groupId>org.custom.portal</groupId>
>    <artifactId>custom-master</artifactId>
>    <name>custom Master Project</name>
>    <description>custom Master Project</description>
>    <packaging>pom</packaging>
>    <version>1.0.0</version>
> 
>    <parent>
>        <groupId>org.apache.rave</groupId>
>        <artifactId>rave-project</artifactId>
>        <version>0.9-incubating-SNAPSHOT</version>
>    </parent>
> 
>    <repositories>
>        <repository>
>            <id>apache-snapshots</id>
>            <name>Apache Software Foundation Snapshots</name>
>            <url>https://repository.apache.org/content/groups/snapshots</url>
>            <snapshots>
>                <enabled>true</enabled>
>            </snapshots>
>        </repository>
>    </repositories>
> 
>    <properties>
>        <rave.version>0.9-incubating-SNAPSHOT</rave.version>
>        <shindig.version>3.0.0-beta4</shindig.version>
>        <cargo.version>1.1.0</cargo.version>
>        <!-- if you want a remote debugging on a different a address override on command line with -Dcargo.debug.address=xxxx -->
>        <cargo.debug.address>8000</cargo.debug.address>
>        <!-- if you want to start remote debugging session suspended  override on command line with -Dcargo.debug.suspend=y -->
>        <cargo.debug.suspend>n</cargo.debug.suspend>
>        <javaagent/>
>    </properties>
> 
>    <dependencyManagement>
>        <dependencies>
>            <dependency>
>                <groupId>org.apache.rave</groupId>
>                <artifactId>rave-portal</artifactId>
>                <version>${rave.version}</version>
>                <type>war</type>
>            </dependency>
>            <dependency>
>                <groupId>org.apache.rave</groupId>
>                <artifactId>rave-shindig</artifactId>
>                <version>${rave.version}</version>
>                <type>war</type>
>            </dependency>
>        </dependencies>
>    </dependencyManagement>
> 
>    <modules>
>        <module>custom-container</module>
>        <module>custom-shindig</module>
>        <module>custom-portal</module>
>    </modules>
> </project>
> 
> =========================
> custom-container/pom.xml:
> 
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> 
>    <modelVersion>4.0.0</modelVersion>
> 
>    <parent>
>        <groupId>org.custom.portal</groupId>
>        <artifactId>custom-master</artifactId>
>        <version>1.0.0</version>
>    </parent>
> 
>    <groupId>org.custom.portal</groupId>
>    <artifactId>custom-container</artifactId>
>    <name>custom::Portal Container</name>
>    <description>custom Portal Container context</description>
>    <packaging>war</packaging>
> 
>    <dependencies>
>        <dependency>
>            <groupId>org.apache.rave</groupId>
>            <artifactId>rave-portal</artifactId>
>            <type>war</type>
>            <exclusions>
>                <exclusion>
>                    <groupId>org.apache.tomcat</groupId>
>                    <artifactId>jasper-el</artifactId>
>                </exclusion>
>                <exclusion>
>                    <groupId>org.apache.tomcat</groupId>
>                    <artifactId>el-api</artifactId>
>                </exclusion>
>                <exclusion>
>                    <groupId>org.glassfish.web</groupId>
>                    <artifactId>jstl-impl</artifactId>
>                </exclusion>
>            </exclusions>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.rave</groupId>
>            <artifactId>rave-core</artifactId>
>            <version>${rave.version}</version>
>            <type>jar</type>
>            <scope>provided</scope>            
>        </dependency>
>        <dependency>
>            <groupId>org.apache.rave</groupId>
>            <artifactId>rave-commons</artifactId>
>            <version>${rave.version}</version>
>            <type>jar</type>
>            <scope>provided</scope>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.rave</groupId>
>            <artifactId>rave-web</artifactId>
>            <version>${rave.version}</version>
>            <type>jar</type>
>            <scope>provided</scope>            
>        </dependency>
> 
>        <!-- Default database -->
>        <dependency>
>            <groupId>com.h2database</groupId>
>            <artifactId>h2</artifactId>
>        </dependency>
> 
>        <dependency>
>            <groupId>org.slf4j</groupId>
>            <artifactId>slf4j-log4j12</artifactId>
>            <scope>provided</scope>
>        </dependency>
> 
>        <!-- test dependencies -->
>        <dependency>
>            <groupId>org.easymock</groupId>
>            <artifactId>easymock</artifactId>
>            <scope>test</scope>
>        </dependency>
>        <dependency>
>            <groupId>org.springframework</groupId>
>            <artifactId>spring-test</artifactId>
>        </dependency>
> 
>    </dependencies>
> </project>
> 
>> -----Original Message-----
>> From: Raminderjeet Singh [mailto:raminderjsingh@gmail.com]
>> Sent: Friday, February 17, 2012 10:04 AM
>> To: rave-dev@incubator.apache.org
>> Subject: Re: Extend Person model as Rave-Extension
>> 
>> Thanks Tony,
>> 
>> I tried the same and it works well for me if i am doing all this in rave-core itself
>> but not as overlay. Can you share the overlay part of you project pom?
>> 
>> Raminder
>> 
>> On Feb 17, 2012, at 9:36 AM, Carlucci, Tony wrote:
>> 
>>> 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:raminderjsingh@gmail.com]
>>>> Sent: Thursday, February 16, 2012 3:30 PM
>>>> To: rave-dev@incubator.apache.org
>>>> 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
> 


RE: Extend Person model as Rave-Extension

Posted by "Carlucci, Tony" <ac...@mitre.org>.
Project Structure:

rave-custom/
     pom.xml
     custom-container/   # this has our overlay code for basically everything but shindig
     custom-shindig/     # this has our overlay code for shindig only (like the shindig.properties, etc)
     custom-portal/      # only has a pom.xml to deploy our custom war files via cargo
          
=============
root pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.custom.portal</groupId>
    <artifactId>custom-master</artifactId>
    <name>custom Master Project</name>
    <description>custom Master Project</description>
    <packaging>pom</packaging>
    <version>1.0.0</version>

    <parent>
        <groupId>org.apache.rave</groupId>
        <artifactId>rave-project</artifactId>
        <version>0.9-incubating-SNAPSHOT</version>
    </parent>

    <repositories>
        <repository>
            <id>apache-snapshots</id>
            <name>Apache Software Foundation Snapshots</name>
            <url>https://repository.apache.org/content/groups/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <properties>
        <rave.version>0.9-incubating-SNAPSHOT</rave.version>
        <shindig.version>3.0.0-beta4</shindig.version>
        <cargo.version>1.1.0</cargo.version>
        <!-- if you want a remote debugging on a different a address override on command line with -Dcargo.debug.address=xxxx -->
        <cargo.debug.address>8000</cargo.debug.address>
        <!-- if you want to start remote debugging session suspended  override on command line with -Dcargo.debug.suspend=y -->
        <cargo.debug.suspend>n</cargo.debug.suspend>
        <javaagent/>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.rave</groupId>
                <artifactId>rave-portal</artifactId>
                <version>${rave.version}</version>
                <type>war</type>
            </dependency>
            <dependency>
                <groupId>org.apache.rave</groupId>
                <artifactId>rave-shindig</artifactId>
                <version>${rave.version}</version>
                <type>war</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <modules>
        <module>custom-container</module>
        <module>custom-shindig</module>
        <module>custom-portal</module>
    </modules>
</project>

=========================
custom-container/pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.custom.portal</groupId>
        <artifactId>custom-master</artifactId>
        <version>1.0.0</version>
    </parent>

    <groupId>org.custom.portal</groupId>
    <artifactId>custom-container</artifactId>
    <name>custom::Portal Container</name>
    <description>custom Portal Container context</description>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>org.apache.rave</groupId>
            <artifactId>rave-portal</artifactId>
            <type>war</type>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>jasper-el</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>el-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.glassfish.web</groupId>
                    <artifactId>jstl-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.rave</groupId>
            <artifactId>rave-core</artifactId>
            <version>${rave.version}</version>
            <type>jar</type>
            <scope>provided</scope>            
        </dependency>
        <dependency>
            <groupId>org.apache.rave</groupId>
            <artifactId>rave-commons</artifactId>
            <version>${rave.version}</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.rave</groupId>
            <artifactId>rave-web</artifactId>
            <version>${rave.version}</version>
            <type>jar</type>
            <scope>provided</scope>            
        </dependency>

        <!-- Default database -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
        </dependency>

    </dependencies>
</project>

>-----Original Message-----
>From: Raminderjeet Singh [mailto:raminderjsingh@gmail.com]
>Sent: Friday, February 17, 2012 10:04 AM
>To: rave-dev@incubator.apache.org
>Subject: Re: Extend Person model as Rave-Extension
>
>Thanks Tony,
>
>I tried the same and it works well for me if i am doing all this in rave-core itself
>but not as overlay. Can you share the overlay part of you project pom?
>
>Raminder
>
>On Feb 17, 2012, at 9:36 AM, Carlucci, Tony wrote:
>
>> 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:raminderjsingh@gmail.com]
>>> Sent: Thursday, February 16, 2012 3:30 PM
>>> To: rave-dev@incubator.apache.org
>>> 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


Re: Extend Person model as Rave-Extension

Posted by Raminderjeet Singh <ra...@gmail.com>.
Thanks Tony, 

I tried the same and it works well for me if i am doing all this in rave-core itself but not as overlay. Can you share the overlay part of you project pom? 

Raminder

On Feb 17, 2012, at 9:36 AM, Carlucci, Tony wrote:

> 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:raminderjsingh@gmail.com]
>> Sent: Thursday, February 16, 2012 3:30 PM
>> To: rave-dev@incubator.apache.org
>> 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


Re: Extend Person model as Rave-Extension

Posted by "anne-helene.turpin@renater.fr" <an...@renater.fr>.
Hi Tony and all,

I've got some questions about your work on extending the User model for 
your internal implementation. I try to do the same for the Person model 
and the person service SPI.
> 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.

What are you declare in the persistence file ?
If I declare the CutomPerson as an Entity in the class but not in the 
persistence file, I can't call declared named queries on it. So I had to 
annotate the CustomPerson model class with @MappedSuperclass and I had 
to declare the CustomPerson in the persistence file in order to use it. 
It's work.
>
> 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
>

I tried the same and it works for me if I'm declaring the 
PersonRepository in the service class but not with the 
CustomPersonRespository. But I can't call the custom method added in the 
CustomPersonRepository. If I declare a CustomPersonrepository in my 
CustomPersonService, I've got this deployment error :

    /org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'customPersonService' defined in URL
    [jar:file:....CustomPersonServiceImpl.class]: Unsatisfied dependency
    expressed through constructor argument with index 1 of type
    [fr.renater.opensocial.repository.impl.CustomPersonRepositoryImpl]:
    : No matching bean of type
    [fr.renater.opensocial.repository.impl.CustomPersonRepositoryImpl]
    found for dependency: expected at least 1 bean which qualifies as
    autowire candidate for this dependency. Dependency annotations: {};
    nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    matching bean of type
    [fr.renater.opensocial.repository.impl.CustomPersonRepositoryImpl]
    found for dependency: expected at least 1 bean which qualifies as
    autowire candidate for this dependency. Dependency annotations: {}/
    /..../
    /Caused by:
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    matching bean of type
    [fr.renater.opensocial.repository.impl.CustomPersonRepositoryImpl]
    found for dependency: expected at least 1 bean which qualifies as
    autowire candidate for this dependency. Dependency annotations: {}/


I don't understand. I create the custom repository class like this :

    /@Repository (value="personRepository")/
    /@Primary/
    /@Transactional/
    /public class CustomPersonRepositoryImpl extends JpaPersonRepository
    implements CustomPersonRepository{...}/

I include component scans of our custom package to the srping 
configuration file.

Which repository do you declare in your CustomUserService ? Can you 
share your experience ?

The original message was posted on the incubator developer mailing list. 
I'm sending a copy to the user mailing list, I think it could be 
interest some people.

Thanks
Anne-Hélène



-- 
Anne-Hélène TURPIN
Renater
Service Applicatif aux Utilisateurs
Tel : +33 2 23 23 71 42


RE: Extend Person model as Rave-Extension

Posted by "Carlucci, Tony" <ac...@mitre.org>.
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:raminderjsingh@gmail.com]
>Sent: Thursday, February 16, 2012 3:30 PM
>To: rave-dev@incubator.apache.org
>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