cancel
Showing results for 
Search instead for 
Did you mean: 

How To extend an authority or person built-in type

mohammed_amr
Champ in-the-making
Champ in-the-making
Dear Gurus,

I have a requirement from certain of customers intended to customize authority or person built-in types.

Simply, i want to add properties to cmSmiley Tongueerson such as "Position" and i walk through the same techniques for alfresco customization of "content types"; but unfortunately all tries are failed.

Also, i read two of posts talks about the same thing

- http://forums.alfresco.com/en/viewtopic.php?t=6553
- http://forums.alfresco.com/en/viewtopic.php?t=6246&start=0&postdays=0&postorder=asc

And may be i'm going in the wrong way, can any one please guide me if there are techniques related to the alfresco configuration file (web-client-config.xml, customModel.xml) because the development way is the final way i would go through to solve the problem.

Thanks In Advance.
Mohammed Amr
6 REPLIES 6

jpotts
World-Class Innovator
World-Class Innovator
You can define aspects and then add those aspects to cmSmiley Tongueerson objects. As those other posts mention, you'll then have to do some work to make that change usable in the web client.

If you are using Share, here is the minimum of what you must do in an Alfresco 3.4 installation to add custom properties to a person object and then use those properties in Share:

1. Extend org.alfresco.web.site.SlingshotUser with your own User class, let's call it SomeUser. Add getters and setters for your properties.

2. Extend org.alfresco.web.site.SlingshotUserFactory with your own Factory class.
2a. Add a buildSomeUser method. Follow existing pattern to build your own.
2b. Add a constructSomeUser method. Follow existing pattern to build your own.
2c. Override constructUser to return SomeUser
2d. Implement saveUser

3. Wire in the custom user factory through Spring using parent="webframework.factory.base"

4. In share-config-custom, override the defaults, user-factory element with a pointer to the new user factory bean

5. Override Alfresco's profile.js with your own.
5a. Modify onEditProfile to include your custom props

6. Extend org/alfresco/components/profile/userprofile.get.html.ftl with your own that includes fields and labels for your custom properties.

There may be some steps I am leaving out but this will get you close.

I have no idea whether or not this has gotten easier in Alfresco 4.

Jeff

jpotts
World-Class Innovator
World-Class Innovator

mohammed_amr
Champ in-the-making
Champ in-the-making
Thanks, already i use the alfresco explorer and i use add aspect techniques.

Thanks.

chrisokelly
Champ on-the-rise
Champ on-the-rise
Hi Jeff,

I know I'm being a bit of a thread necromancer here, but there seems to be some differences between the 2 posts you have here in this thread. On your post on the 16th Feb, it says that one must extend the SlingshotUser class. It also says that when extending SlingshotUserFactory that the buildUser, ConstructUser, and saveUser methods must be implemented/overridden. In the tutorial on your site and also in the sample code it is a much sparser process, with nothing to do with the SlingshotUser class, and only the constructUser and SaveUser methods implemented. Which of these is correct?

jpotts
World-Class Innovator
World-Class Innovator
The difference is that in my Feb 15 post, I was outlining what was done on a project that was likely 3.4.x Enterprise.

A week or so later I felt bad that I hadn't provided a working example, but not owning the IP of the 3.4.x Enterprise example, I had to re-code it from scratch, and I chose to use 3.4.d Community Edition. As you observed, I was able to do that without touching SlingshotUser and with fewer method overrides.

This could be because:
- The two releases of Alfresco are different
- My contrived example was simpler than what we were doing in that original project
- My second attempt was simply more succinct than the first

I cannot tell which of these is the case without a deeper investigation which I don't have time to do at the moment.

I can say with certainty that both worked at the time they were written for the release they were written against.

Jeff

chrisokelly
Champ on-the-rise
Champ on-the-rise
Hi Jeff,

That makes sense. I was worried that some of the extra stuff from the first post was just so obvious to people in the know that it didn't need to be in the tutorial. I wasn't able to figure out a way to get that solution to work in 4.0d, but produced a rather messy workaround in the end.