<?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>Doga Berntas &#187; gae/j</title>
	<atom:link href="http://doganberktas.com/tag/gaej/feed/" rel="self" type="application/rss+xml" />
	<link>http://doganberktas.com</link>
	<description>is actually from a small planet somewhere in the vicinity of Betelgeuse</description>
	<lastBuildDate>Sat, 21 Apr 2012 21:48:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>So How Do You Convince Google App Engine to Create Your Datastore Indexes</title>
		<link>http://doganberktas.com/2010/09/03/so-how-do-you-convience-google-app-engine-to-create-your-datastore-indexes/</link>
		<comments>http://doganberktas.com/2010/09/03/so-how-do-you-convience-google-app-engine-to-create-your-datastore-indexes/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 14:11:47 +0000</pubDate>
		<dc:creator>dkberktas</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[e-tohum]]></category>
		<category><![CDATA[etohum]]></category>
		<category><![CDATA[gae]]></category>
		<category><![CDATA[gae/j]]></category>
		<category><![CDATA[index]]></category>

		<guid isPermaLink="false">http://doganberktas.com/?p=606</guid>
		<description><![CDATA[Creating indexes on Google App Engine / Java (gae/j) is an easy job. You don&#8217;t even have to think about it (well, for some time) For etohum admin application we used gae/j and it has been almost two years and gae/j has been improved a lot, but still, it has some really annoying features (bugs [...]]]></description>
			<content:encoded><![CDATA[<p>Creating indexes on Google App Engine / Java (gae/j) is an easy job. You don&#8217;t even have to think about it (well, for some time)</p>
<p>For <a href="http://doganberktas.com/tag/e-tohum/">etohum</a> admin application we used gae/j and it has been almost two years and gae/j has been improved a lot, but still, it has some really annoying features (bugs &#8212; I am not sure how to named them).</p>
<p>This time, it is the <strong>Datastore Indexes</strong>. Some of the pages requires indexes like</p>
<p><img style="margin-top: 5px; margin-bottom: 5px;" src="http://doganberktas.com/wp-content/uploads/2010/09/Screen-shot-2010-09-03-at-4.48.10-PM.png" alt="" width="500" height="21" /></p>
<p>which turns out to be confusing for the auto generation tool. If, let&#8217;s say, you change the order of the last two fields,</p>
<p>like this</p>
<p><img style="margin-top: 5px; margin-bottom: 5px;" src="http://doganberktas.com/wp-content/uploads/2010/09/Screen-shot-2010-09-03-at-4.48.02-PM.png" alt="" width="500" height="21" /></p>
<p>you will not get it automatically.</p>
<p>Even if you explicitly define it in your  <strong>datastore-indexes.xml</strong> file</p>
<pre>&lt;datastore-index kind="Application" ancestor="false" source="manual"&gt;
 &lt;property name="applciationIsFinished" direction="asc"/&gt;
 &lt;property name="isSpam" direction="asc"/&gt;
 &lt;property name="sezonId" direction="asc"/&gt;
 &lt;property name="bitisTarihi" direction="desc"/&gt;
 &lt;property name="basvuruTarihi" direction="desc"/&gt;
 &lt;/datastore-index&gt;
</pre>
<p>And the workaround for the problem is stated in the last paragraph of <a href="http://code.google.com/appengine/docs/java/config/indexconfig.html#Using_Automatic_Index_Configuration">Using Automatic Index Configuration documentation</a></p>
<blockquote><p>It&#8217;s a good idea to occasionally move index configuration from <code>datastore-indexes-auto.xml</code> to <code>datastore-indexes.xml</code>,  then disable automatic index configuration and test your app in the  development server.  This makes it easy to maintain indexes without  having to manage two files, and ensures that your testing will reproduce  errors caused by missing index configuration.</p></blockquote>
<p>So change the <strong>datastore-indexes.xml</strong> file and add manually the all required indexes and upload the application.</p>
<pre>&lt;datastore-indexes autoGenerate="false"&gt;</pre>
<p>You can change it back to auto generate after make sure the desired indexes are created.</p>
<p>ps. A tip about gae/j is that it is considerable faster when it is 4AM-7AM at the west coast of North America.</p>
]]></content:encoded>
			<wfw:commentRss>http://doganberktas.com/2010/09/03/so-how-do-you-convience-google-app-engine-to-create-your-datastore-indexes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing Paging on Google App Engine Java (gae/j) and GWT &#8212; the query cursor way</title>
		<link>http://doganberktas.com/2010/08/12/implementing-paging-on-google-app-engine-java-gaej-and-gwt-the-query-cursor-way/</link>
		<comments>http://doganberktas.com/2010/08/12/implementing-paging-on-google-app-engine-java-gaej-and-gwt-the-query-cursor-way/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 19:18:07 +0000</pubDate>
		<dc:creator>dkberktas</dc:creator>
				<category><![CDATA[gwt]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[gae/j]]></category>
		<category><![CDATA[query cursors]]></category>

		<guid isPermaLink="false">http://doganberktas.com/?p=556</guid>
		<description><![CDATA[For the etohum admin application application, we used Goole App Engine Java (gae/j) two years ago, back then, the way to implement paging was not that easy. Because of that we came up with our custom way and implemented a combination of memcached+servlet+cron jobs update mechanism which introduced many bugs and took many hours to [...]]]></description>
			<content:encoded><![CDATA[<p>For the <a href="http://e-tohum.appspot.com/">etohum admin application</a> application, we used Goole App Engine Java (gae/j) two years ago, back then, the way to implement paging was not that <a href="http://code.google.com/appengine/articles/paging.html">easy</a>. Because of that we came up with our custom way and implemented a combination of memcached+servlet+cron jobs update mechanism which introduced many bugs and took many hours to reach perfection.</p>
<p><img src="http://doganberktas.com/wp-content/uploads/2010/08/Screen-shot-2010-08-12-at-10.17.57-PM.png" alt="" width="495" height="266" /></p>
<p>Since <a href="http://burakbuyukdemir.com/">Burak hoca</a> asks for an enhancements recently, we go through the app engine documentation and see this new feature <a href="http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html#Query_Cursors">query cursors</a> which is excellent for paging.</p>
<p>The idea behind query cursors is pretty simple, make a query for the first page, pass the cursor data to the client. When you need the second page,  instead of  making a query from scracth, use the cursor data to get the next page&#8217;s data.</p>
<p>In our case the RPC call  <strong>getApplications(String cursor)</strong> is called. For the first page, cursor data is passed as null, so we make the query as follows:</p>
<pre>if (cursorString == null)
{
	//
	Query query = pm.newQuery(Application.class);
	query.setOrdering("basvuruTarihi desc");
	query.setRange(0, 15);

	results = (List) query.execute();

	Cursor cursor = JDOCursorHelper.getCursor(results);
	resultWrapper.setCursorData(<strong>cursor.toWebSafeString()</strong>);

	for (Iterator iterator = results.iterator(); iterator.hasNext();)
	{
		Application applicationFromDatabase = (Application) iterator.next();
		app = DunyaTurkOlsunUtil.createApplicationDTO(applicationFromDatabase);
		resultAppList.add(app);
	}
	resultWrapper.setResultAppList(resultAppList);
}
</pre>
<p>So this code above fetch the first page and cursor string. On the client side, inside GWT, we hold the cursor string for each page in an arraylist, so that we can handle going back and forth between the pages.</p>
<p>When the user asks for the second pages, the following code block executes</p>
<pre>else
{
	Cursor cursor = Cursor.fromWebSafeString(cursorString);
	Map extensionMap = new HashMap();
	extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, cursor);
	Query query = pm.newQuery(Application.class);
	query.setOrdering("basvuruTarihi desc");

	query.setExtensions(extensionMap);
	query.setRange(0, 15);

	results = (List) query.execute();
	resultWrapper.setCursorData(JDOCursorHelper.getCursor(results).toWebSafeString());

	for (Iterator iterator = results.iterator(); iterator.hasNext();)
	{
		Application applicationFromDatabase = (Application) iterator.next();
		app = DunyaTurkOlsunUtil.createApplicationDTO(applicationFromDatabase);
		//
		resultAppList.add(app);
	}
	resultWrapper.setResultAppList(resultAppList);
}

//
This works even faster than memcached version of ours. 

ps. By the way, there is still no way of passing JDO objects through RPC calls which is sad for GWT apps on GAE/J/
</pre>
]]></content:encoded>
			<wfw:commentRss>http://doganberktas.com/2010/08/12/implementing-paging-on-google-app-engine-java-gaej-and-gwt-the-query-cursor-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Twitter oauth on GAE/J</title>
		<link>http://doganberktas.com/2010/01/26/using-twitter-oauth-on-gaej/</link>
		<comments>http://doganberktas.com/2010/01/26/using-twitter-oauth-on-gaej/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:22:03 +0000</pubDate>
		<dc:creator>dkberktas</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[appengine-web.xml]]></category>
		<category><![CDATA[gae/j]]></category>
		<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java platform]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Twitter Inc]]></category>
		<category><![CDATA[twitter oauth]]></category>
		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://doganberktas.com/?p=212</guid>
		<description><![CDATA[Twitter supports oauth and there are many libraries for it, for  Java(twitter4J)(oauth-signpost),  most of the time you see examples of a desktop version, so it can take time to implement it on a web application (it did take time for my case). Step 1. Get a Twitter account and create a Twitter application from http://twitter.com/apps [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter supports <a href="http://apiwiki.twitter.com/OAuth-FAQ">oauth </a>and there are many libraries for it, for  Java(<a href="http://twitter4j.org/en/index.html#introduction">twitter4J</a>)(<a href="http://code.google.com/p/oauth-signpost/">oauth-signpost</a>),  most of the time you see examples of a desktop version, so it can take time to implement it on a web application (it did take time for my case).</p>
<p>Step 1. Get a Twitter account and create a Twitter application from http://twitter.com/apps (don&#8217;t forget to check in browser and enter a  valid callback url. <a href="http://doganberktas.com/wp-content/uploads/2010/01/2.jpg"><img class="size-full wp-image-218 alignnone" title="2" src="http://doganberktas.com/wp-content/uploads/2010/01/2.jpg" alt="" width="523" height="536" /></a></p>
<p>Step 2.  Download <a href="http://twitter4j.org/en/index.html#download">twitter4J</a> add the library (in my case twitter4j-core-2.1.1-SNAPSHOT.jar) to project and update classpath</p>
<p>Step 3. Create a <a href="http://code.google.com/eclipse/docs/getting_started.html#creating">web application</a> (I assume you have the <a href="http://code.google.com/eclipse/">Google plugin for Eclipse </a>)</p>
<p><a href="http://doganberktas.com/wp-content/uploads/2010/01/1.jpg"><img class="size-full wp-image-219 alignnone" title="1" src="http://doganberktas.com/wp-content/uploads/2010/01/1.jpg" alt="" width="455" height="559" /></a></p>
<p>Step 4. Add the following servlets and update your web.xml. First servlet will handle login part. It will create a RequestToken which will create the magical aggrements between the consumer(your application) and provider(twitter). First servlet save the  token and secret token since we will need them later.</p>
<pre>String token = requestToken.getToken();
String tokenSecret = requestToken.getTokenSecret();
</pre>
<ul>
<li><a href="http://code.google.com/p/dogansartifacts/source/browse/trunk/GoogleAppEngineJava/TwiitterClient/src/a/b/c/server/HomeServlet.java">Home servlet</a></li>
<li><a href="http://code.google.com/p/dogansartifacts/source/browse/trunk/GoogleAppEngineJava/TwiitterClient/src/a/b/c/server/LoginServlet.java">Login Servlet</a></li>
</ul>
<p>Step 5. You forget to update web.xml didn&#8217;t you, update the web.xml</p>
<p>Step 6.  Enable <a href="http://code.google.com/appengine/docs/java/config/appconfig.html#Enabling_Sessions">session</a> by adding</p>
<pre>    &lt;sessions-enabled&gt;true&lt;/sessions-enabled&gt;
</pre>
<p>to appengine-web.xml.</p>
<p>You can see my version from <a href="http://90.latest.denemekaya.appspot.com/login">http://90.latest.denemekaya.appspot.com/login</a></p>
<p>ps. don&#8217;t forget to set the callback in Twittter to the url of the servlet for callback.</p>
<p>Links:</p>
<ul>
<li>http://www.pakzilla.com/2009/10/03/tutorial-java-based-twitter-app-on-google-app-engine/</li>
<li>Explain the same procedure with Grails &#8212; http://blogs.bytecode.com.au/glen/2009/12/08/log-into-your-grails-app-using-your-twitter-credentials.html</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://doganberktas.com/2010/01/26/using-twitter-oauth-on-gaej/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using Memcache with Google App Engine (GAE/J)</title>
		<link>http://doganberktas.com/2010/01/18/using-memcache-with-google-app-engine-gaej-a-simple-beginning-fragman-iphone-application/</link>
		<comments>http://doganberktas.com/2010/01/18/using-memcache-with-google-app-engine-gaej-a-simple-beginning-fragman-iphone-application/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 21:39:23 +0000</pubDate>
		<dc:creator>dkberktas</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[gae]]></category>
		<category><![CDATA[gae/j]]></category>
		<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[ifragman]]></category>
		<category><![CDATA[iphone application]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Servlet]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Memcached]]></category>
		<category><![CDATA[Technology/Internet]]></category>

		<guid isPermaLink="false">http://doganberktas.com/?p=196</guid>
		<description><![CDATA[A simple beginning &#8212; Fragman iPhone Application Memcache provides convenience to store a frequent query in memory, so that you don&#8217;t have to make the same execution over and over again. For the iPhone application I build (Fragman), I build a GAE/J backend for managing movie names, IMDB URLs, thumb images, video files, etc. It [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A simple beginning &#8212; Fragman iPhone Application</strong></p>
<p>Memcache provides convenience to store a frequent query in memory, so that you don&#8217;t have to make the same execution over and over again. For the <a href="http://ifragman.com"><span style="color: #800000;">iPhone application I build (Fragman</span></a><span style="color: #800000;">)</span>, I build a GAE/J backend for managing movie names, IMDB URLs, thumb images, video files, etc. It interacts with the Obj-c code via calls encoded in JSON.</p>
<p>Since the categories are updated so frequently (new trailer, top 250 , soap opera trailers), every time the user starts the application from her iPhone, the corresponding categories Id(key) lists are  created which includes all the aspects mentioned above,</p>
<p>what I see, after people start to use the application that, most of the time, the application got stuck with the time constraint of GAE and  this causes inconvenience, so I decided to hold the category lists&#8217;s JSON in memory. Following is the code ,</p>
<p>this is the servlet for creating the JSON which is called after say upcoming movie list is changed. This servlet updates the memcached list</p>
<pre>        List keyList = new ArrayList();
	static Cache cache;
	static
	{
		try
		{
			CacheFactory cacheFactory =</pre>
<pre>CacheManager.getInstance().getCacheFactory();
			cache = cacheFactory.createCache(</pre>
<pre>Collections.emptyMap());
		}
		catch (CacheException e)
		{
			// ...
		}
		//.....
                public void doGet(HttpServletRequest request,</pre>
<pre>HttpServletResponse response) throws ServletException, IOException</pre>
<pre>	        {
                       //................
                       if(cache.containsKey(mode))
		       {
			     cache.remove(mode);
		       }
		       cache.put(mode, keyList);
	        }</pre>
<pre>                //........</pre>
<pre>          }</pre>
<p>And this is the servlet that fetch the Fragman beans from the datastore with the given keys (key list is got from the memecached list)</p>
<pre>          keyList = (List)cache.get(mode);</pre>
<pre>By doing this, I reduce the time that the servlet that creates the JSON takes.</pre>
]]></content:encoded>
			<wfw:commentRss>http://doganberktas.com/2010/01/18/using-memcache-with-google-app-engine-gaej-a-simple-beginning-fragman-iphone-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

