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

Wednesday, July 1, 2009

Calculate Day from provided date in Java

Hi,

This blog explains you to calculate the Day of the week when the date is provided

Here is the java code

String date = "06302009";
SimpleDateFormat sdf = new SimpleDateFormat( "MMddyyyy" );
Date d = sdf.parse(date);
Date d2;
System.out.println("D is - "+d.getDay());

This will give you the day value on 30th of July 2009
(0- Sunday, 1- Monday, 2- Tuesday, 3- Wednesday, 4- Thursday, 5- Friday, 6- Saturday)

Monday, November 10, 2008

Alfresco FTP Socket Error


I was getting the JVM_Bind error in tomcat console while starting, that was because of FTP Server error 
I have commented the alfresco FTP code and its working fine for me now - - - 
Here is what i have done - - -


Disabled FTP by commenting out the FTP bean in the
projects/repository/config/alfresco/bootstrap-context.xml file:



–>





If you are not able to find bootstrap-context.xml file, search for it in alfresco folder








Tuesday, October 14, 2008

TimeStamp format

Many of us use the time format in our code
But very few of us knows the meaning of using the format.
Here is the explaination of these codes,very useful --- 

TimeStamp format as follows:
H = 24 Hour
HH = 24 Hour with leading zero
h = 12 Hour
hh = 12 Hour with leading zero
m = Minutes
mm = Minutes with leading zero
s = Seconds
ss = Seconds with leading zero
t = A/P
tt = AM/PM

Example:

[H:mm]------------->[23:59] (24 hour time)
[h:mm]------------->[11:59] (12 hour time)
[H:mm:ss]--------->[23:59:59] (24 hour with seconds counter)
[h:mm:ss]--------->[11:59:59] (12 hour with seconds counter)
[H:mm:sstt]------->[23:59:59pm] (24 hour with seconds counter and AM/PM) but its 24 hour, you shouldnt need it.
[h:mm:sstt]------->[11:59:59] (12 hour with seconds counter and AM/PM)

You are not required to use the [Square Bracket notation] you may use anything just so long as it contains a TimeStamp format. Note: Please ensure that you use the correct case (UPPER/lower)