<?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>stejan&#039;s Welt &#187; Programming</title>
	<atom:link href="http://www.stejan.ch/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stejan.ch</link>
	<description>ste oder jan</description>
	<lastBuildDate>Sat, 14 Jan 2012 22:08:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>FULL JOIN in MySQL</title>
		<link>http://www.stejan.ch/2009/12/01/full-join-in-mysql/</link>
		<comments>http://www.stejan.ch/2009/12/01/full-join-in-mysql/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:31:46 +0000</pubDate>
		<dc:creator>stejan</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[full]]></category>
		<category><![CDATA[join]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.stejan.ch/?p=586</guid>
		<description><![CDATA[Schon mal gefragt, wie man ein FULL JOIN in MySQL macht? Dann gibt&#8217;s hier einige Lösungen. http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/ Ähnliche ArtikelKeine weiteren Artikel]]></description>
			<content:encoded><![CDATA[<p>Schon mal gefragt, wie man ein FULL JOIN in MySQL macht?</p>
<p>Dann gibt&#8217;s hier einige Lösungen.<br />
<a href="http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/">http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/</a></p>
<h2  class="related_post_title">Ähnliche Artikel</h2><ul class="related_post"><li>Keine weiteren Artikel</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.stejan.ch/2009/12/01/full-join-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CQ and 401/404</title>
		<link>http://www.stejan.ch/2009/04/09/cq-and-401404/</link>
		<comments>http://www.stejan.ch/2009/04/09/cq-and-401404/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 22:29:05 +0000</pubDate>
		<dc:creator>stejan</dc:creator>
				<category><![CDATA[CQ]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[401]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[closed user group]]></category>
		<category><![CDATA[cq5]]></category>
		<category><![CDATA[cug]]></category>

		<guid isPermaLink="false">http://www.stejan.ch/?p=413</guid>
		<description><![CDATA[In the newest version of Day CQ WCM there is one big problem about the HTTP Response Status 401 and 404. My problem: I wanted to make a CUG (Closed User Group). So I set the permissions as I expected in CQ4: On a call to this locked page I expected a 401 Not Authorized [...]]]></description>
			<content:encoded><![CDATA[<p>In the newest version of <a title="DAY CQ WCM" href="http://www.day.com/content/day/en/products/web_content_management.html" target="_blank">Day CQ WCM</a> there is one big problem about the HTTP Response Status 401 and 404.</p>
<p>My problem: I wanted to make a CUG (Closed User Group).</p>
<p>So I set the permissions as I expected in CQ4:</p>
<p><img class="alignnone size-thumbnail wp-image-415" title="pagestructure" src="http://www.stejan.ch/wp-content/2009/03/pagestructure-150x150.png" alt="pagestructure" width="150" height="150" /><img class="alignnone size-thumbnail wp-image-416" title="surfer_rights" src="http://www.stejan.ch/wp-content/2009/03/surfer_rights-150x150.png" alt="surfer_rights" width="150" height="150" /><img class="alignnone size-thumbnail wp-image-417" title="cug_rights" src="http://www.stejan.ch/wp-content/2009/03/cug_rights-150x150.png" alt="cug_rights" width="150" height="150" /></p>
<p>On a call to this locked page I expected a <em>401 Not Authorized</em> and a login page or login box. But what I got was a <em>404 Page Not Found</em>. Hmmm strange!!</p>
<p><img class="alignnone size-thumbnail wp-image-422" title="cug_404" src="http://www.stejan.ch/wp-content/2009/03/cug_404-150x150.png" alt="cug_404" width="150" height="150" /></p>
<p>This implementation is (on my opinion) really wrong. With this implementation it&#8217;s never possible to create a CUG accessed page.</p>
<p>But there is a workaround:</p>
<ul>
<li>copy the file /libs/sling/servlet/errorhandler/404.jsp to /apps.</li>
<li>get the <a title="Admin Session" href="http://www.stejan.ch/?p=409">admin session</a></li>
<li>check (with the admin session) if the required page exists</li>
<li>if so &#8211;&gt; send 401</li>
<li>else send 404</li>
</ul>
<pre class="brush: java">...
if(isClosedUserGroup(sling, resource)){
  response.setStatus(401);
  response.addHeader("WWW-Authenticate", "Basic realm=\"myrealm\"");
} else {
  response.setStatus(404);

%&gt;&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;404 Not Found&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Not Found&lt;/h1&gt;
&lt;p&gt;The requested URL &lt;%=request.getRequestURI()%&gt;
      was not found on this server.&lt;/p&gt;
&lt;hr&gt;
&lt;address&gt;
&lt;%=this.getServletConfig().getServletContext().getServerInfo()%&gt;
&lt;/address&gt;
&lt;/body&gt;&lt;/html&gt;&lt;%
}
...</pre>
<p>That&#8217;s it.</p>
<h2  class="related_post_title">Ähnliche Artikel</h2><ul class="related_post"><li>7.März 2009 -- <a href="http://www.stejan.ch/2009/03/07/how-to-get-the-admin-session/" title="How to get the admin session">How to get the admin session</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.stejan.ch/2009/04/09/cq-and-401404/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the admin session</title>
		<link>http://www.stejan.ch/2009/03/07/how-to-get-the-admin-session/</link>
		<comments>http://www.stejan.ch/2009/03/07/how-to-get-the-admin-session/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 21:47:26 +0000</pubDate>
		<dc:creator>stejan</dc:creator>
				<category><![CDATA[CQ]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[admin session]]></category>
		<category><![CDATA[cq5]]></category>
		<category><![CDATA[julian]]></category>
		<category><![CDATA[sedding]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.stejan.ch/?p=409</guid>
		<description><![CDATA[I now work since 3 months with cq5 and I realy like it. But there are so many new things to learn!! For example the thing: How do I have to get the admin session? Thanks Julian for your help. I would never get it myself.    final SlingRepository repo = sling.getService(SlingRepository.class); final JcrResourceResolverFactory resolverFactory =  [...]]]></description>
			<content:encoded><![CDATA[<p>I now work since 3 months with cq5 and I realy like it. But there are so many new things to learn!!</p>
<p>For example the thing: <strong>How do I have to get the admin session?</strong></p>
<p>Thanks Julian for your help. I would never get it myself. </p>
<p> </p>
<pre>final SlingRepository repo = sling.getService(SlingRepository.class);
final JcrResourceResolverFactory resolverFactory = 
      sling.getService(JcrResourceResolverFactory.class);</pre>
<pre>final Session admin;
try {
   admin = repo.loginAdministrative(null);
} catch (RepositoryException e) {
   // If we can't get the admin session it's safer to assume no CUG
   sling.getResponse().getWriter().println("Admin session not available...");
   return false;
}

//Access to the Sling API
final ResourceResolver adminResourceResolver =
      resolverFactory.getResourceResolver(admin);

//Access to the CQ5 Page-API
PageManager adminPageManager = adminResourceResolver.adaptTo(PageManager.class);

final Resource adminResource = adminResourceResolver.resolve(resource.getPath());

//To get to the resource or page the following should give you a pointer:
final Page page = adminPageManager.getContainingPage(adminResource);</pre>
<div><span><br />
</span></div>
<h2  class="related_post_title">Ähnliche Artikel</h2><ul class="related_post"><li>9.April 2009 -- <a href="http://www.stejan.ch/2009/04/09/cq-and-401404/" title="CQ and 401/404">CQ and 401/404</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.stejan.ch/2009/03/07/how-to-get-the-admin-session/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

