Wednesday

Tweet My World Portlet

Hello everyone

The joy of creating something is something which cannot be expressed.
The idea of this portlet struck to me because Julio. When I created Google Chartlet, Julio posted the same to Twitter. I thought why not create something which could automate this. The result is Tweet My World Portlet

Features
  • Sets Twitter Status as soon as some new content is added in the available assets
  • Twitter Credentials configurable via control panel
  • Supports Wikis, Blogs and Software Catalog right now
  • Creates small url using Bit.ly internally
  • Set twitter credentials individually for organization, community or per user. For example, you can configure twitter credential for your organization and also you can do the same for your Community. So if there is a blog post in your community public page, twitter status get set for that particular Twitter account, similary if you have configured it for your organization, status would be set for the twitter account that you have configured for organization
How To Use?
  • Usage is pretty simple. Go to the Control Panel.
  • Click Tweet My World under content section.
  • Set your Twitter Credentials.
  • Select the assets for which you want to set the status when content is added.
Example
  • For guest community select Blogs from Tweet My World section. Make sure your twitter credentials are correct.
  • Place a public blog in one of the pages of your Guest community.
  • Add a blog post. 
  • Login to the twitter account you have configured. The  status must appear there.
  • Thats it. You are done.
Note: You wont get any error if you don't fill any of the above or details are partially filled, apart from the fact that, if you do so, the status won't be set.

Improvements
  • Right now the status that is set is in English. I wish i could apply some I18N there.
  • More assets can be identified and added.
  • Right now status is only set when someone has added a blog post or wiki page. It could be modified further if someone edits blog post or for other actions.
Links
SourceForge
Community Download page
JTwitter Page
Bit.ly api
Forum

ScreenShots



Have a nice day!!

------Update------

Gustavo Fernandez has found a problem  with my portlet behind proxy and solution for it. Please check this entry
http://www.zylk.net/web/guest/web-2-0/blog/-/blogs/using-jtweet-portlet-behind-a-proxy-for-twittering-liferay-contents
Thanks Gustavo.

Friday

Google Chartlet - Yipeee!!!! My First Portlet for community

I am very glad to announce that I have created a portlet to display Google Charts. I have named it as Google Chartlet in sourceforge.

I feel so good about it as
  • Its my first portlet that i am creating for community. Glad to give back something to community
  • First time I am using sourceforge.
This portlet is made using charts4j.

This portlet has very limited functionality as of now.

What it has?


User Charts

  • Shows total users, organizations and communities in the system (2D and 3D pie charts)
  • Show number of users in the organization (2D and 3D Pie chart)
  • Number of users registered with system for current year(Bar chart)
Asset Chart
  • Shows distribution of assets in system(2D and 3D pie charts)
Sample Charts
  • These are basically the same charts that are listed in charts4j project page. They are static charts, but show the power of Google charts and Charts4j api.
How to Configure?
  • This portlet basically is an instanceable portlet. So you can create multiple instances of portlet on same page.
  • Configuring is pretty much simple. You will see Configure button as soon as you add the portlet.
  • Clicking on that you are provided with two step process of selecting the type of report and type of chart.
  • Once you have done that you will be shown the chart.
  • You can click on settings if you have configure permission, where you can set the report title, width and height of report.
What next?
  • I want ideas to create new report types.
  • Right now the color of the report is predefined too. It would be nice if that is configurable as well.
  • Your comments to improve are very much welcome.
Download Link

Screenshots


Wednesday

Allow user to delete his own comments for any commentable asset

The Problem

In the assets where user can comment like blog, journal article and the rest, users should have Delete Discussion Permission for that particular asset to delete comment.

You can test this by commenting on a blog entry. Now give that user Delete Discussion permission for Blog.

Now the problem is, if he is given Delete Discussion permission, he is able to delete any users comment.

What I wanted was like user should be able to delete his own comments.

Solution - Hook to the rescue
  • Commenting comes from liferay:ui discussion. So I created a jsp hook for the same.
  • In the jsp hook, recreate this folder structure html/taglib/ui/discussion/page.jsp under your jsps or whatever folder you have configured for the jsp hook
  • We have to modify page.jsp, so edit the same.Find the below line.
    There are two occurances for the same.

  • <c:if test=\"<%= MBDiscussionPermission.contains(permissionChecker, company.getCompanyId(), scopeGroupId, className, classPK, userId, ActionKeys.DELETE_DISCUSSION)
  • Basically this is the condition that allows user to delete a comment.
  • Now here we want to add an additional condition that if the logged in user has created the comment he should be able to delete the comment.
  • So replace the above line with following for both the occurances of above line.

  • <c:if test=\"<%= MBDiscussionPermission.contains(permissionChecker, company.getCompanyId(), scopeGroupId, className, classPK, userId, ActionKeys.DELETE_DISCUSSION) || (themeDisplay.getUserId() == message.getUserId()) %>\">
  • Deploy the hook.Thats it. Now the user should be able to delete his own comments not anyone else's.

Thursday

Implementing SSL in Liferay with Apache Web Server

CheckLists & Pre-requisites

Configuring Apache Web Server with Liferay - http

Apache WebServer Changes

  • Make sure Apache Web server is running. Open your favorite browser and type http://localhost

  • You should be able to see a page which displays "It works"

  • Go to your Apache installation directory and open httpd.conf file under conf directory

  • Uncomment the following lines

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

LoadModule proxy_connect_module modules/mod_proxy_connect.so

LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

LoadModule proxy_http_module modules/mod_proxy_http.so

  • At the very end of the file append the following

ProxyRequests On

ProxyPass / http://localhost:8080/

ProxyPassReverse / http://localhost:8080/

  • Restart Apache Web server

Liferay Changes

  • Open you portal-ext.properties in Liferay

  • Add the following lines

web.server.http.port=80

web.server.https.port=443

  • Restart Liferay.

  • Open your browser and type http://localhost.

  • You should be able to see your liferay homepage.

  • You have configured Liferay to use with Apache web server


Creating Self-signed SSL certificate

Pre-requisites

  • Open the OpenSSL toolkit that you have installed

Generating Private Key

  • The first step is to create your RSA Private Key.

  • This key is a 1024 bit RSA key which is encrypted using Triple-DES and stored in a PEM format so that it is readable as ASCII text.

  • On the toolkit command prompt type the following

genrsa -des3 -out server.key 1024

  • It will create server.key

Generate a CSR(Certificate Signing Request)

  • Once the private key is generated a Certificate Signing Request can be generated.

  • The CSR is then used in one of two ways. Ideally, the CSR will be sent to a Certificate Authority, such as Thawte or Verisign who will verify the identity of the requestor and issue a signed certificate.

  • The second option is to self-sign the CSR, which we will do.

  • During the generation of the CSR, you will be prompted for several pieces of information.

  • The command to generate the CSR is as follows

req -new -key server.key -out server.csr

Remove Passphrase from key

  • Make another copy of server.key and name it as server.key.org

  • Type the following in ssl toolkit command prompt

rsa -in server.key.org -out server.key

Generate a self-signed certificate

  • At this point you will need to generate a self-signed certificate because you either don't plan on having your certificate signed by a CA, or you wish to test your new SSL implementation while the CA is signing your certificate.

  • This temporary certificate will generate an error in the client browser to the effect that the signing certificate authority is unknown and not trusted.

  • To generate a temporary certificate which is good for 365 days, issue the following command

x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

  • You should have server.key, server.csr and server.crt generated at this step


Configuring Apache Web Server with Liferay - https

  • Copy server.key, server.csr and server.crt generated to conf directory of Apache.

  • Open httpd.conf in Apache and uncomment the following lines to enable mod_ssl and configuration file for https

LoadModule ssl_module modules/mod_ssl.so

Include conf/extra/httpd-ssl.conf

  • Restart your Apache web server

  • Open your browser and type https://localhost

  • You should be able to see your liferay main page in https

Configuring login and create account page for https

  • Open your portal-ext.properties and add the following property

company.security.auth.requires.https=true

  • Restart your tomcat

  • Open your browser and type http://localhost

  • Click on sign in or create account page. This should change the protocol to https

  • Enter your credentials and Login to the application. The protocol should change back to http when user is logged in.

Disabling https with apache web server

  • Comment out or remove the following properties in portal-ext.properties

web.server.http.port=80

web.server.https.port=443

company.security.auth.requires.https=true

  • Restart the tomcat.

  • This would make Tomcat run alone without apache. You have to access application using http://localhost:8080