<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Intelligrape  Groovy &#38; Grails Blogs</title>
	<atom:link href="http://www.intelligrape.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.intelligrape.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 17 May 2012 11:51:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
			<title>Intelligrape  Groovy &amp; Grails Blogs</title>
			<url>http://www.intelligrape.com/blog/wp-content/uploads/2011/05/favicon2.ico</url>
			<link>http://www.intelligrape.com/blog</link>
			<width></width>
			<height></height>
			<description></description>
		</image>		<item>
		<title>get totalCount of records when using limit in one Query</title>
		<link>http://www.intelligrape.com/blog/2012/05/17/get-totalcount-of-records-when-using-limit-in-one-query/</link>
		<comments>http://www.intelligrape.com/blog/2012/05/17/get-totalcount-of-records-when-using-limit-in-one-query/#comments</comments>
		<pubDate>Thu, 17 May 2012 11:51:11 +0000</pubDate>
		<dc:creator>Shaurav</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5559</guid>
		<description><![CDATA[For pagination we generally execute two query ,first for geting resultset by using limit in sql query and second to count the total no. of records . For total no. of records we again execute the same query with count(*).
You would need two queries like these:

SELECT COUNT(*) FROM author WHERE name LIKE 'a%';

SELECT name, email [...]]]></description>
			<content:encoded><![CDATA[<p>For pagination we generally execute two query ,first for geting resultset by using limit in sql query and second to count the total no. of records . For total no. of records we again execute the same query with count(*).</p>
<p>You would need two queries like these:</p>
<pre class="brush: java;">
SELECT COUNT(*) FROM author WHERE name LIKE 'a%';

SELECT name, email FROM author WHERE name LIKE 'a%' LIMIT 10;
</pre>
<p>But if you have a complex query that joins several tables and takes a while to execute – well, you probably wouldn’t want to execute it twice and waste server resources.</p>
<p>Since MYSQL 4.0 we can use<strong> SQL_CALC_FOUND_ROWS</strong> option in  query which will tell MySQL to count total number of rows <strong><em>disregarding LIMIT clause</em></strong>. In main query add <strong>SQL_CALC_FOUND_ROWS</strong> option just after SELECT and in second query  use <strong>FOUND_ROWS()</strong> function to get total number of rows without executing the query.</p>
<p>Queries would look like this:</p>
<pre class="brush: java;">
SELECT SQL_CALC_FOUND_ROWS name, email FROM author WHERE name LIKE 'a%' LIMIT 10;

SELECT FOUND_ROWS();
</pre>
<p><strong>Limitation:</strong> Must call second query immediately after the first one(or before next one) because SQL_CALC_FOUND_ROWS does not save number of rows anywhere.In the absence of the SQL_CALC_FOUND_ROWS option in the most recent successful SELECT statement, FOUND_ROWS() returns the number of rows in the result set returned by that statement.<br />
<span id="more-5559"></span><br />
Shaurav Kumar<br />
[Intelligrape Software Pvt. Ltd.]<br />
<!--more--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/05/17/get-totalcount-of-records-when-using-limit-in-one-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overriding properties in a Spring Bean with BeanFactoryPostProcessor</title>
		<link>http://www.intelligrape.com/blog/2012/05/12/overriding-properties-in-a-spring-bean-with-beanfactorypostprocessor/</link>
		<comments>http://www.intelligrape.com/blog/2012/05/12/overriding-properties-in-a-spring-bean-with-beanfactorypostprocessor/#comments</comments>
		<pubDate>Sat, 12 May 2012 08:37:53 +0000</pubDate>
		<dc:creator>Vivek Krishna</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[bean post processing]]></category>
		<category><![CDATA[spring internals]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5550</guid>
		<description><![CDATA[I was going through the source code of one of the Grails Plugins where I found the use of Spring&#8217;s BeanDefinitionRegistryPostProcessor to override some configurations that are available in DataSource.groovy. That involved a complete over riding of a PropertyValue definition.
&#160;
It set me thinking about whether there is a way to override bean properties like String, [...]]]></description>
			<content:encoded><![CDATA[<p>I was going through the source code of one of the Grails Plugins where I found the use of Spring&#8217;s <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/beans/factory/support/BeanDefinitionRegistryPostProcessor.html" target="_blank">BeanDefinitionRegistryPostProcessor</a> to override some configurations that are available in DataSource.groovy. That involved a complete over riding of a <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/beans/PropertyValue.html" target="_blank">PropertyValue</a> definition.</p>
<p>&nbsp;</p>
<p>It set me thinking about whether there is a way to override bean properties like String, Integer etc in a simpler way after the bean has initialized. In comes <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/beans/factory/config/BeanFactoryPostProcessor.html" target="_blank">BeanFactoryPostProcessor</a>, which provides a wonderful hook to do just that.</p>
<p>&nbsp;</p>
<p>I created a small grails project and added a class CustomBean which looked like this :</p>
<pre class="brush: java;">

class CustomBean {
       String customVariable
}
</pre>
<p>I registered a <em>customBean</em> on resources.groovy using</p>
<pre class="brush: java;">
beans = {
    customBean(CustomBean) {
        String value = &quot;Test Data From resources.groovy&quot;
        println &quot;Setting value ${value}&quot;
        customVariable = value
    }

    customBeanPostProcessor(CustomBeanPostprocessor)
}
</pre>
<p>This sets the initial value of <em>customVariable</em> as &#8220;Test Data From resources.groovy&#8221;.</p>
<p>If you are wondering what the customBeanPostprocessor is, that is just what I am going to explain next.<br />
The bean implements the BeanFactoryPostProcessor interface and overrides the methods which provides us with hooks to modify the properties of the bean.</p>
<p>&nbsp;</p>
<p>The class definition is:</p>
<pre class="brush: java;">
import groovy.util.logging.Log4j
import org.springframework.beans.factory.config.BeanPostProcessor

@Log4j
class CustomBeanPostprocessor implements BeanPostProcessor{

    @Override
    Object postProcessBeforeInitialization(Object bean, String beanName) {
        return bean
    }

    @Override
    Object postProcessAfterInitialization(Object bean, String beanName) {
        if(beanName == 'customBean') {
            log.debug(&quot;Setting custom value inside post processor&quot;)
            bean.customVariable = &quot;Set from Post Processor&quot;
        }
        return bean
    }
}
</pre>
<p>What amazed me is the elegance with which the developers of the framework has provided entry points into its internals without forcing the users to shave the yak.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/05/12/overriding-properties-in-a-spring-bean-with-beanfactorypostprocessor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change user preferred locale using spring&#8217;s SessionLocaleResolver</title>
		<link>http://www.intelligrape.com/blog/2012/05/11/change-user-preferred-locale-using-springs-sessionlocaleresolver/</link>
		<comments>http://www.intelligrape.com/blog/2012/05/11/change-user-preferred-locale-using-springs-sessionlocaleresolver/#comments</comments>
		<pubDate>Fri, 11 May 2012 05:01:34 +0000</pubDate>
		<dc:creator>Nitesh</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[gsp]]></category>
		<category><![CDATA[HTTP session]]></category>
		<category><![CDATA[lang]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[RequestContextUtils]]></category>
		<category><![CDATA[SessionLocaleResolver]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5478</guid>
		<description><![CDATA[Here we are going to talk about a scenario where there are some records in database which are specific to locale and they need to be displayed as per user&#8217;s current locale at number of places.Also user can change its preferred locale.
For this I preferred to set the user&#8217;s locale in the session object. There [...]]]></description>
			<content:encoded><![CDATA[<p>Here we are going to talk about a scenario where there are some records in database which are specific to locale and they need to be displayed as per user&#8217;s current locale at number of places.Also user can change its preferred locale.</p>
<p>For this I preferred to set the user&#8217;s locale in the session object. There are two ways to do this :-</p>
<p>1. Add attribute &#8220;lang&#8221; to the request and it will be available to session automatically.</p>
<p>For example: whenever user clicks on the link, the language will change to English and the user will remain on the same page.<strong><br />
</strong></p>
<pre class="brush: groovy;">

&lt;g:link controller=&quot;${params.controller}&quot; action=&quot;${params.action}&quot; params=&quot;${params+[lang:'en']}&quot;&gt;English&lt;/g:link&gt;
/*Add different languages here*/
</pre>
<p>2.Also set default locale in the session in case, it is not set.</p>
<p>For that add following to any Filters :-</p>
<pre class="brush: groovy;">

if (!session.'org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE') {
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
localeResolver.setLocale(request, response, new Locale('en'));

}
</pre>
<p>This sets the locale in spring&#8217;s SessionLocaleResolver class. Session always refer for the locale from here only.</p>
<p>Now one can check the locale wherever session is available. For example in GSPs:</p>
<pre class="brush: groovy;">

&lt;g:if test=&quot;${session.'org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE'.toString()=='en'}&quot;&gt;
</pre>
<p><strong>Note</strong>: This implementation is useful to set locale in session (for accessing many times). Otherwise locale is available directly from current request as given below:-</p>
<pre class="brush: groovy;">
import org.springframework.web.servlet.support.RequestContextUtils as RCU
Locale locale=RCU.getLocale(request)
</pre>
<p>Hope this helped!<br />
Nitesh Goel<br />
[Intelligrape Software Pvt. Ltd.]</p>
<div style="width: 1px;height: 1px;overflow: hidden">RequestContextUtils</div>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/05/11/change-user-preferred-locale-using-springs-sessionlocaleresolver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fetching File From FTP in Background With Curl.</title>
		<link>http://www.intelligrape.com/blog/2012/05/09/fetching-file-from-ftp-in-background-with-curl/</link>
		<comments>http://www.intelligrape.com/blog/2012/05/09/fetching-file-from-ftp-in-background-with-curl/#comments</comments>
		<pubDate>Tue, 08 May 2012 21:27:34 +0000</pubDate>
		<dc:creator>Hitesh Bhatia</dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[ftp]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5457</guid>
		<description><![CDATA[Last night I had to restore file with size greater  than 220GB  from our  backup FTP server to our main server after OS re installation.
Now I could have simply done “get”  after logging into ftp out server, but that would have required my machine to stay awake all night unattended. Seems [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I had to restore file with size greater  than 220GB  from our  backup FTP server to our main server after OS re installation.</p>
<p>Now I could have simply done “get”  after logging into ftp out server, but that would have required my machine to stay awake all night unattended. Seems simple but everything I tried didn&#8217;t seem to work .</p>
<p>In comes curl, literally saved my night. With simple command written below I was able to transfer file from ftp server to local machine.</p>
<pre class="brush: bash;"> curl ftp://name:password@server/file.tar &gt; file.tar</pre>
<p>And then it was piece of cake running it in background with nohup</p>
<pre class="brush: bash;">nohup curl ftp://name:password@server/file.tar &gt; file.tar &amp;</pre>
<p>Thanks to curl, me and my system were able to get good nights sleep <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div>_________________________________</div>
<div>Hitesh Bhatia<br />
<a href="mailto:hitesh@intelligrape.com" target="_blank">Mail</a> <a href="http://in.linkedin.com/in/bhatiahitesh" target="_blank">LinkedIn</a>,<a href="http://www.facebook.com/home.php?#%21/profile.php?id=100000114437286" target="_blank">Facebook</a>,<a href="http://twitter.com/d1_ricky" target="_blank">Twitter</a><br />
_________________________________</div>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/05/09/fetching-file-from-ftp-in-background-with-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restricting Access To Plugin&#8217;s Classes With Spring Security</title>
		<link>http://www.intelligrape.com/blog/2012/05/03/restricting-access-to-plugins-classes-with-spring-security/</link>
		<comments>http://www.intelligrape.com/blog/2012/05/03/restricting-access-to-plugins-classes-with-spring-security/#comments</comments>
		<pubDate>Thu, 03 May 2012 08:55:42 +0000</pubDate>
		<dc:creator>Hitesh Bhatia</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Annotations]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[searchable]]></category>
		<category><![CDATA[spring security]]></category>
		<category><![CDATA[static roles]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5447</guid>
		<description><![CDATA[Many of Grails plugin like  searchable  and console can prove to be really dangerous if access to their URLs is not blocked. After adding searchable plugin to my  project, I realized that access to its controllers was not defined and was open for all. Now this was a major security concern. There  [...]]]></description>
			<content:encoded><![CDATA[<p>Many of Grails plugin like  searchable  and console can prove to be really dangerous if access to their URLs is not blocked. After adding searchable plugin to my  project, I realized that access to its controllers was not defined and was open for all. Now this was a major security concern. There  are many ways of restricting access like doing it manually in filters. But since I am using spring security plugin, there was a better way out. It allows to create mapping (static rules) as configuration for different user roles.</p>
<p>There are different ways of securing url in spring security plugin. And since I am using annotations, I&#8217;ll be defining static rule for annotations only.</p>
<pre class="brush: java;">

grails.plugins.springsecurity.controllerAnnotations.staticRules = [

'/console/**': ['ROLE_ADMIN'],

'/searchable/**': ['ROLE_ADMIN']

]
</pre>
<p>By doing this I blocked access for all but ones with the role &#8220;ROLE_ADMIN&#8221;  for console and searchable controllers.</p>
<div>_________________________________</div>
<div>Hitesh Bhatia<br />
<a href="http://in.linkedin.com/in/bhatiahitesh" target="_blank">Mail,LinkedIn</a>,<a href="http://www.facebook.com/home.php?#%21/profile.php?id=100000114437286" target="_blank">Facebook</a>,<a href="http://twitter.com/d1_ricky" target="_blank">Twitter</a><br />
_________________________________</div>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/05/03/restricting-access-to-plugins-classes-with-spring-security/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Multiple Bootable OS in Single USB</title>
		<link>http://www.intelligrape.com/blog/2012/04/19/multiple-bootable-os-in-single-usb/</link>
		<comments>http://www.intelligrape.com/blog/2012/04/19/multiple-bootable-os-in-single-usb/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 11:11:55 +0000</pubDate>
		<dc:creator>Hitesh Bhatia</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Multiboot]]></category>
		<category><![CDATA[Multiboot USB]]></category>
		<category><![CDATA[MultiSystem]]></category>
		<category><![CDATA[System Installation]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5430</guid>
		<description><![CDATA[Recently I have been knee deep into Linux installations. Installing through  USB is great process,  there is  no hassle of CD and its faster too. But problem is first we need bootable USB. Up till now I used &#8220;Start Disk Creator&#8221;, which is bundled in Ubuntu and is great for creating bootable USB, major problem with [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been knee deep into Linux installations. Installing through  USB is great process,  there is  no hassle of CD and its faster too. But problem is first we need bootable USB. Up till now I used &#8220;Start Disk Creator&#8221;, which is bundled in Ubuntu and is great for creating bootable USB, major problem with it is that it  creates single boot USB, that is If I have bootable USB for Ubuntu 11.04, it will be erased when I create a bootable stick for Ubuntu 11.10.</p>
<p>This was a problem for me, and I found a solution to this problem in Multisystem, which creates a single bootable USB for multiple OS.<br />
Here are steps to install And Use Multisystem<br />
1) Download From <a href="//liveusb.info/multisystem/install-depot-multisystem.sh.tar.bz2">PenDriveLinux.com</a>, Extract the package .. change the permission of extracted file &#8220;install-depot-multisystem.sh&#8221; to make it executable.</p>
<p>2) Execute this file and it&#8217;ll download some files, and complete its installation. After Its Done, lets move to actually creating Pen Drive with multiple bootable OS.</p>
<p>3) Run Multisystem and it&#8217;ll ask you to confirm any USB drive if inserted. Once confirmed it  should look as following images, but there would be no OS pre configured. (it shows some as I configured them, it also tells me that I have  4live CDs already configured.)<br />
<img class="alignleft" src="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/Image-1.png" alt="Multisystem" width="402" height="450" /><img src="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/Image-1-.B.png" alt="Multisystem Home Screen" /><br />
4) Click on icon at bottom in middle (Which has “Select .iso or .img “written on top of it). And Select  image file of OS for which bootable USB need to be created. It&#8217;ll again ask for password and within  less than a minute bootable will be ready.</p>
<p>5)Same process (step 4) can be repeated to add multiple OS to bootable USB stick.</p>
<p>6) It also lets you test how bootable stick will work.Just Click on &#8220;Q&#8221; button and see the magic. Below are the images of me testing ArchBang from my bootable USB.<br />
<img src="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/archbang-1.png" alt="Multisystem Boot" width="600" /><br />
<img src="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/archbang-2.png" alt="Archbang 1" width="600" /><br />
<img src="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/archbang-3.png" alt="Archbang 2" width="600" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/04/19/multiple-bootable-os-in-single-usb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling corrupted references through ignoreNotFound database mapping in Grails</title>
		<link>http://www.intelligrape.com/blog/2012/04/17/handling-corrupted-references-through-ignorenotfound-database-mapping-in-grails/</link>
		<comments>http://www.intelligrape.com/blog/2012/04/17/handling-corrupted-references-through-ignorenotfound-database-mapping-in-grails/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 12:39:35 +0000</pubDate>
		<dc:creator>Tarun Pareek</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[corrupted]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[ignoreNotFound]]></category>
		<category><![CDATA[not-found=true]]></category>
		<category><![CDATA[references]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5415</guid>
		<description><![CDATA[Hi,
&#160;
Recently i had a use-case where we have the legacy database and it contains the corrupted references of a non existent record in many-to-one relationship, and i have to populate a grid that contain info also from referenced record. As referenced record doesn&#8217;t exist, So when we refer to the certain record will result in [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
&nbsp;<br />
Recently i had a use-case where we have the legacy database and it contains the corrupted references of a non existent record in many-to-one relationship, and i have to populate a grid that contain info also from referenced record. As referenced record doesn&#8217;t exist, So when we refer to the certain record will result in Hibernate throwing exception :
<pre class="brush: java;">org.hibernate.ObjectNotFoundException</pre>
<p> and not a single record loaded on grid.<br />
&nbsp;<br />
As it is legacy database i am not sure what should be the correct value for the particular record. <br />
&nbsp;<br />
After few searches, i come accross a property in grails database mapping to handle such cases, let see how it work :</p>
<pre class="brush: java;">
class Task{
   String name
   ParentTask parent

   static mapping = {
       parent ignoreNotFound: true
   }
}

class ParentTask{
   String name
}
</pre>
<p>Basically, ignoreNotFound simply mapping hibernate not-found property.<br />
&nbsp;<br />
<strong>Note : A record loaded with ignoreNotFound: true will throw an exception during call of save() because of the missing reference.</strong><br />
&nbsp;<br />
Either you can first update the invalid property or corrupted reference to the correct reference and then update other property that will solve your problem. It depend how you handle such scenario on your usecase.<br />
&nbsp;<br />
Thanks,<br />
Tarun Pareek<br />
tarun@intelligrape.com<br />
<a href="http://in.linkedin.com/in/tarunpareek">http://in.linkedin.com/in/tarunpareek</a><br />
<a href="http://www.intelligrape.com/blog/author/tarun/">More Blogs by Me</a><br />
&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/04/17/handling-corrupted-references-through-ignorenotfound-database-mapping-in-grails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating Grails with Weceem</title>
		<link>http://www.intelligrape.com/blog/2012/04/16/integrating-grails-with-weceem/</link>
		<comments>http://www.intelligrape.com/blog/2012/04/16/integrating-grails-with-weceem/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 10:54:38 +0000</pubDate>
		<dc:creator>manoj</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[blogs]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[marc palmer]]></category>
		<category><![CDATA[weceem]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5101</guid>
		<description><![CDATA[Today, I&#8217;ll be talking on how to go about integrating the Weceem CMS into a grails-app. It is extremely simple and with a couple of steps you would have a CMS that can render traditional as well as custom content merged into your grails application.

Ok &#8230; First things first &#8230; What is Weceem ?
Weceem (as in [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I&#8217;ll be talking on how to go about integrating the Weceem CMS into a grails-app. It is extremely simple and with a couple of steps you would have a CMS that can render traditional as well as custom content merged into your grails application.</p>
<p style="padding-bottom: 10px">
<h5><strong>Ok &#8230; First things first &#8230; What is Weceem ?</strong></h5>
<p>Weceem (as in &#8216;We seem&#8217; to like it <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ) is a Content Management System developed by Marc Palmer for JCatalog that is built on Grails. It is open source and easy to use.  <em>Apart from being customizable, the other thing that I liked  about it was the ability to create custom content, and that too using grails conventions!!.</em></p>
<p><em> </em></p>
<p><em>While it supports traditional content like Blogs, Wiki articles etc, one had the flexibility and support of creating a custom content that might be more in line with the hosting grails app.</em> Add to that the ease of a grails plugin that makes it&#8217;s integration with an existing grails app a breeze.</p>
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<h5><strong>Getting back to Installation &#8230;..</strong></h5>
<p style="padding-bottom: 10px">To install weceem simply type</p>
<pre class="brush: bash;">grails install-plugin weceem</pre>
<p style="padding-bottom: 10px">While installing, it will pull a whole lotta stuff as it&#8217;s dependencies (searchable, blueprint , ckeditor etc).</p>
<p>Next to see the plugin&#8217;s CMS page, one needs to configure a couple of properties.</p>
<p>1)   In your Config.groovy change the follwing line to false ….</p>
<pre class="brush: groovy;">grails.mime.file.extensions = false //set to true by default</pre>
<p>2)  Next  if you need content to be served from the root URI (&#8216;/&#8217;) of your application, simply remove the default grails URL mapping for &#8216;/&#8217; URLMappings.groovy.i.e doing this will cause the app home page to change to the CMS home page.</p>
<p>Thats all you need to have Weceem up and running.</p>
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p><em>Simply hit &#8216;grails run-app&#8217; and depending on your implementation of Step 2 above either hit &#8216;/&#8217; or &#8216;wcmContent/show&#8217; and <strong>VOILA!!!</strong>, you end up on the landing page of the CMS. Click on the &#8216;edit content repository&#8217; link to go to the Content Repository that looks something like the image below&#8230;</em></p>
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<div id="attachment_5232" class="wp-caption aligncenter" style="width: 594px"><a href="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/startup.png"><img class="size-full wp-image-5232  " style="border: solid 2px #bbbbbb" src="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/startup.png" alt="Weceem CMS landing page" width="584" height="445" /></a><p class="wp-caption-text">Weceem CMS landing page</p></div>
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">You have a grails powered CMS integrated into your app in matter of minutes. Click on the new content link button, and you are presented with a range of content options … from HTML to Blogs to Wiki pages and so on.</p>
<p style="padding-bottom: 10px">
<h5><strong>Great &#8230; Lets create some content &#8230;</strong></h5>
<p style="padding-bottom: 10px">First select existing Blog folder in the CMS dashboard  and then click on  the &#8216;New Content&#8217; -&gt; Blog Entry ..</p>
<p style="padding-bottom: 10px">Add some content &#8230;</p>
<p style="padding-bottom: 10px"><a href="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/Screenshot-at-2012-04-16-140536.png"><img class="size-full wp-image-5328 alignleft" style="border: solid 2px #bbbbbb" src="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/Screenshot-at-2012-04-16-140536.png" alt="" width="468" height="233" /></a></p>
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px"><em>Thats it &#8230; All you gotta do now is hit save.</em></p>
<p style="padding-bottom: 10px">Now to view our content &#8230; Go to the blogs page of your app (URI for page is defined in &#8216;Alias uri&#8217; section of Blogs folder-edit page.. Default is &#8216;blog&#8217;) or <strong>&#8220;http://&lt;serverURL&gt;/blog&#8221;</strong></p>
<p><strong>Tip : </strong><em>To serve all content through a specific URI prefix .. just add</em>
<pre class="brush: groovy;">weceem.content.prefix = 'content' // replace 'content' with anything you prefer ... </pre>
<p><em>to make your blogs page and all other repository content be served from </em> <strong>http://&lt;serverURL&gt;/content/&lt;blog_or_anything_else&gt;</strong></p>
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px"></p>
<p style="padding-bottom: 10px">
<p><a href="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/Screenshot-at-2012-04-16-141445.png"><img class="size-full wp-image-5326 alignleft" style="border: solid 2px #bbbbbb" src="http://www.intelligrape.com/blog/wp-content/uploads/2012/04/Screenshot-at-2012-04-16-141445.png" alt="" width="467" height="251" /></a></p>
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<p><strong><em>In the next blog, I&#8217;ll talk how to go about creating your own custom content .. </em></strong></p>
<p>Till then &#8230; peace out .. <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="padding-bottom: 10px">
<p style="padding-bottom: 10px">
<div>Manoj Mohan</div>
<div>manoj<span style="text-decoration: line-through">(at)</span>intelligrape<span style="text-decoration: line-through">(dot)</span>com</div>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/04/16/integrating-grails-with-weceem/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Clear Time function for MySQL</title>
		<link>http://www.intelligrape.com/blog/2012/04/12/clear-time-function-for-mysql/</link>
		<comments>http://www.intelligrape.com/blog/2012/04/12/clear-time-function-for-mysql/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 06:36:09 +0000</pubDate>
		<dc:creator>Gaurav Sharma</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Clear Time]]></category>
		<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5302</guid>
		<description><![CDATA[Hi all,
Here is a simple function that can allow you to clear time from the DATETIME field of your database table

DROP FUNCTION IF EXISTS cleartime;
delimiter //
CREATE FUNCTION cleartime(dt datetime) RETURNS DATETIME
  NO SQL
  DETERMINISTIC
BEGIN
  DECLARE t    varchar(15);             [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>Here is a simple function that can allow you to clear time from the DATETIME field of your database table</p>
<pre class="brush: sql;">
DROP FUNCTION IF EXISTS cleartime;
delimiter //
CREATE FUNCTION cleartime(dt datetime) RETURNS DATETIME
  NO SQL
  DETERMINISTIC
BEGIN
  DECLARE t    varchar(15);               -- the time part of the dt
  DECLARE rdt  datetime default dt;    	  -- the datetime after time part is cleared

  SET t = TIME(dt);
  SET rdt = SUBTIME(dt,t);

  RETURN rdt;
END //
delimiter ;
</pre>
<p>To import this function to your database just copy and paste above code in MySQL command prompt with your database selected.</p>
<p>The implementation is shown in following example:</p>
<pre class="brush: sql;">
select cleartime(datetime_field) from table_name;     -- to view field with its time cleared
                     --OR
update table_name set datetime_field=cleartime(datetime_feild) from table_name;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/04/12/clear-time-function-for-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dealing with immutable collections in Java</title>
		<link>http://www.intelligrape.com/blog/2012/04/11/dealing-with-immutable-collections-in-java/</link>
		<comments>http://www.intelligrape.com/blog/2012/04/11/dealing-with-immutable-collections-in-java/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 13:39:18 +0000</pubDate>
		<dc:creator>Salil</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[collections]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=5276</guid>
		<description><![CDATA[Perhaps, you know it before or just skipped it after going through Java API. But I really found it very helpful at this point.
&#160;
Recently, I had a requirement in an open-source project, where users can iterate through the objects saved in collections (esp. List). But the problem was, we really didn’t want users to directly [...]]]></description>
			<content:encoded><![CDATA[<p>Perhaps, you know it before or just skipped it after going through Java API. But I really found it very helpful at this point.</p>
<p>&nbsp;</p>
<p>Recently, I had a requirement in an open-source project, where users can iterate through the objects saved in collections (esp. List). But the problem was, we really didn’t want users to directly or indirectly update those collection objects. Or in other words, we wanted to provide them collections with Read-Only behavior.</p>
<p>&nbsp;</p>
<p><strong>So to fulfill this requirement,</strong> I had few solutions -<br />
1) Writing a wrapper class for iterating the objects in collection, in a manner that it behaves like Immutable collection objects.<br />
2) Implementing your own Collection classes to support read-only behavior.<br />
3) Returning the output as Iterable.<br />
4) And many more &#8211; as complicated as we want to make it.</p>
<p>&nbsp;</p>
<p>Well, need not to worry guys!<br />
<strong>Java provides an in-built class &#8220;<a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Collections.html">java.util.Collections</a>&#8220;</strong> &#8211; to deal with such kind of problems.</p>
<p>Collections class comes up with a good list of static methods. Like, for converting a modifiable list to unmodifiable list (read-only list), we have following method:</p>
<pre class="brush: java;">
List myUnmodifiableList = Collections.unmodifiableList(myModifiableList)
</pre>
<p>and now, if anyone will try to modify &#8216;myUnmodifiableList&#8217;, it will throw <strong>UnsupportedOperationException</strong>.<br />
Similarly, there are other methods to handle different types of collections.</p>
<p>&nbsp;</p>
<p>I hope this might help someone.</p>
<p>&nbsp;</p>
<p>Please put your comment, if there&#8217;s any better way out there.</p>
<p>&nbsp;</p>
<p>Cheers!<br />
Salil Kalia<br />
Salil [at] IntelliGrape [dot] com<br />
<a href="http://twitter.com/salil_kalia" target="_blank">Twitter</a> <a href="http://in.linkedin.com/in/salilkalia" target="_blank">LinkedIn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2012/04/11/dealing-with-immutable-collections-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

