Search This Blog

About Me

Highly experienced in implementation and customization of Alfresco. More than 11 years of experience working on Alfresco, versions ranging from 2.x to 5.x. Successfully processed innovative and tailored CMS solutions to meet ever-changing business requirements for multiple clients. Role Includes : Experience in Alfresco Upgrades, SOLR migration, Proposals, Team Handling, Delivery, Content Migration, POC's etc.. Extensive experience in client co ordination, working on offshore-onshore model and project take over. Technical Expertise Includes : Java, JSP, Servlet, JSF, JavaScript, AJAX, Spring, SQL, Hibernate, Web Services(REST). Specialities Includes : Content Migration, Product Customization, Business CMS Solutions, Workflow, Project Transition.

Wednesday, December 23, 2009

Getting the list of groups the user is a member of..in Alfresco


Hello Guys,

Here is the code or just a function to find out the groups of which user is a member of.
Please find the below code, you can use it from any class just by passing ApplicationContext and the Group Name as a parameters.

public static boolean isCurrentUserInGroup(ApplicationContext context, String groupName)
{
// The authority service returns authorities with their AuthorityDAO type
// prefix prepended to the name, so we'll do that as well
groupName = AuthorityType.GROUP.getPrefixString() + groupName;
final ServiceRegistry serviceRegistry = (ServiceRegistry)
context.getBean(ServiceRegistry.SERVICE_REGISTRY);
// get the current user
String currentUserName =
serviceRegistry.getAuthenticationService().getCurrentUserName();
// get the list of groups this user is a member of
Set authorityList = serviceRegistry.getAuthorityService().getContainingAuthorities
(AuthorityType.GROUP, currentUserName, false);
System.out.println("authorityList--"+authorityList);
// look in the list to see if groupName is in there. If so, return true;
return authorityList.contains(groupName);
}



Tuesday, December 8, 2009

Running SDK FirstFoundationClient



FirstFoundationClient is the first project you tries to run from eclipse IDE
Do the following set ups before you run its main method

1. In custom-repository.properties file inside package source.alfresco.extension

Set paths of dir.root and dir.indexes
e.g

dir.root=D:/myAlfresco/alf_data
dir.indexes=D:/myAlfresco/alf_data/lucene-indexes

Also provide the driver and database details of the database you are using
e.g, In my case, i have used postgreSQL database, so details will be

db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://localhost:5432/myalfresco
db.username=myalfresco
db.password=myalfresco

2. In custom-alfresco-shared.properties file inside package source.alfresco.extension
un comment avm.jmxrmi.port and avm.remote.port ( you can change the port numbers if getting jmxrmi port error while running FFC)


3. If you are not having custom-hibernate-dialect.properties inside package source.alfresco.extension, you can copy it from here. (remove txt extension)
Un comment your hibernate dialect property with respect to your database.
I have uncommented for my postgreSQL databse

4. Register your hibernate file in custom-repository-context.xml file inside package source.alfresco.extension. You can check my file here. (remove txt extension)

5. Now start your alfresco server and run FirstFoundationClient.java. hope you will get it running successfully. Restart the server and you will see a new file in company home space.



Note - You may get bind error, but it won't effect your program.
One more thing i forgot to mention, upload respective database jar into SDK FFC project build path.


thanks,
Anuj