<?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>cat brain.stuff &#62; wordpress &#187; Uncategorized</title>
	<atom:link href="http://famvdploeg.com/blog/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://famvdploeg.com/blog</link>
	<description>A simple look on things</description>
	<lastBuildDate>Fri, 30 Jul 2010 13:01:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Deserializing XML twitter feeds.</title>
		<link>http://famvdploeg.com/blog/2010/07/deserializing-xml-twitter-feeds/</link>
		<comments>http://famvdploeg.com/blog/2010/07/deserializing-xml-twitter-feeds/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 10:08:41 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[deserialize]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xsd]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=172</guid>
		<description><![CDATA[1. Use xsd.exe to extract an xsd file from an xml feed. Download a private xml feed for example from &#8220;http://api.twitter.com/1/statuses/user_timeline.xml&#8221; and store it to local disk. Use xsd.exe to generate the xsd. 2. Generate the classes from the xsd file you just generated. xsd.exe yourxsd.xsd /c 3. Add the generated classes to your C# [...]]]></description>
			<content:encoded><![CDATA[<p>1. Use xsd.exe to extract an xsd file from an xml feed.<br />
Download a private xml feed for example from &#8220;http://api.twitter.com/1/statuses/user_timeline.xml&#8221; and store it to local disk. Use xsd.exe to generate the xsd.<br />
2. Generate the classes from the xsd file you just generated.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xsd.exe yourxsd.xsd <span style="color: #000000; font-weight: bold;">/</span>c</pre></div></div>

<p>3. Add the generated classes to your C# project.<br />
4. Time for some fetching here is a short example:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// encode the username/password</span>
<span style="color: #993333;">string</span> user <span style="color: #339933;">=</span> Convert.<span style="color: #202020;">ToBase64String</span><span style="color: #009900;">&#40;</span>System.<span style="color: #202020;">Text</span>.<span style="color: #202020;">Encoding</span>.<span style="color: #202020;">UTF8</span>.<span style="color: #202020;">GetBytes</span><span style="color: #009900;">&#40;</span>username <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #339933;">+</span> password<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
HttpWebRequest request <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>HttpWebRequest<span style="color: #009900;">&#41;</span>WebRequest.<span style="color: #202020;">Create</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;http://api.twitter.com/1/statuses/user_timeline.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// set the method to GET</span>
request.<span style="color: #202020;">Method</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;GET&quot;</span><span style="color: #339933;">;</span>
request.<span style="color: #202020;">ServicePoint</span>.<span style="color: #202020;">Expect100Continue</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// set the authorisation levels</span>
request.<span style="color: #202020;">Headers</span>.<span style="color: #202020;">Add</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Authorization&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Basic &quot;</span> <span style="color: #339933;">+</span> user<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
request.<span style="color: #202020;">ContentType</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;application/x-www-form-urlencoded&quot;</span><span style="color: #339933;">;</span>
&nbsp;
using <span style="color: #009900;">&#40;</span>HttpWebResponse response <span style="color: #339933;">=</span> request.<span style="color: #202020;">GetResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> as HttpWebResponse<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	XmlSerializer serializer <span style="color: #339933;">=</span> new XmlSerializer<span style="color: #009900;">&#40;</span>typeof<span style="color: #009900;">&#40;</span>statuses<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	statuses s <span style="color: #339933;">=</span> serializer.<span style="color: #202020;">Deserialize</span><span style="color: #009900;">&#40;</span>response.<span style="color: #202020;">GetResponseStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> as statuses<span style="color: #339933;">;</span>
&nbsp;
	listBox1.<span style="color: #202020;">Items</span>.<span style="color: #202020;">Clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	foreach <span style="color: #009900;">&#40;</span>statusesStatus status in s.<span style="color: #202020;">status</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		listBox1.<span style="color: #202020;">Items</span>.<span style="color: #202020;">Add</span><span style="color: #009900;">&#40;</span>status.<span style="color: #202020;">text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2010/07/deserializing-xml-twitter-feeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jackrabbit configuration</title>
		<link>http://famvdploeg.com/blog/2010/04/jackrabbit-configuration/</link>
		<comments>http://famvdploeg.com/blog/2010/04/jackrabbit-configuration/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 07:58:35 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=156</guid>
		<description><![CDATA[1. Download the jackrabbit jca from http://jackrabbit.apache.org/downloads.html 2. Deploy it on glassfish 3. Create a new Resource Adapter Configuration &#40;Create a new Thread-pool first if you want&#41; 4. Create a new Connector Connection Pool with the new Resource Adapter Configuration Add the following properties: homeDir &#60;full path to where your repository is located&#62; configFile &#60;full [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">1. Download the jackrabbit jca from http:<span style="color: #000000; font-weight: bold;">//</span>jackrabbit.apache.org<span style="color: #000000; font-weight: bold;">/</span>downloads.html
2. Deploy it on glassfish
3. Create a new Resource Adapter Configuration <span style="color: #7a0874; font-weight: bold;">&#40;</span>Create a new Thread-pool first <span style="color: #000000; font-weight: bold;">if</span> you want<span style="color: #7a0874; font-weight: bold;">&#41;</span>
4. Create a new Connector Connection Pool with the new Resource Adapter Configuration
Add the following properties:
homeDir <span style="color: #000000; font-weight: bold;">&lt;</span>full path to where your repository is located<span style="color: #000000; font-weight: bold;">&gt;</span>
configFile <span style="color: #000000; font-weight: bold;">&lt;</span>full path to where your repository config <span style="color: #7a0874; font-weight: bold;">&#40;</span>repository.xml<span style="color: #7a0874; font-weight: bold;">&#41;</span> is located<span style="color: #000000; font-weight: bold;">&gt;</span>
5. Create the connector resource and name it <span style="color: #ff0000;">'jcr/repository'</span> <span style="color: #000000; font-weight: bold;">for</span> example.</pre></div></div>

<p>You can now access your repository in the code. Below is a sample.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.famvdploeg.jackrabbit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.annotation.Resource</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.ejb.Stateless</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Node</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Repository</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Session</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.SimpleCredentials</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author wytze
 */</span>
@Stateless
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JackrabbitManager <span style="color: #009900;">&#123;</span>
&nbsp;
	@Resource<span style="color: #009900;">&#40;</span>mappedName<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;jcr/repository&quot;</span>, type<span style="color: #339933;">=</span>javax.<span style="color: #006633;">jcr</span>.<span style="color: #003399;">Repository</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Repository</span> repository<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getFromRepo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			Session session <span style="color: #339933;">=</span> repository.<span style="color: #006633;">login</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> SimpleCredentials<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username&quot;</span>, <span style="color: #0000ff;">&quot;password&quot;</span>.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Node root <span style="color: #339933;">=</span> session.<span style="color: #006633;">getRootNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Node hello <span style="color: #339933;">=</span> root.<span style="color: #006633;">addNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			hello.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;message&quot;</span>, <span style="color: #0000ff;">&quot;Hello, World!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			session.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Retrieve content</span>
            		Node node <span style="color: #339933;">=</span> root.<span style="color: #006633;">getNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>node.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>node.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;message&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			root.<span style="color: #006633;">getNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hello&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Created and removed!&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A possible Java EE 6 Servlet which you can use for WebDAV support. You will need jackrabbit-jcr-server for the base servlet. You can get it by building the source package with maven.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.famvdploeg.jackrabbit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.annotation.PostConstruct</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.ejb.EJB</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Repository</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.annotation.WebServlet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.annotation.WebInitParam</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author wytze
 */</span>
@WebServlet<span style="color: #009900;">&#40;</span>
	name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;webdav&quot;</span>,
	urlPatterns <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/repository/*&quot;</span>,
	initParams <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		@WebInitParam<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;resource-path-prefix&quot;</span>, value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/repository&quot;</span><span style="color: #009900;">&#41;</span>,
		@WebInitParam<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;missing-auth-mapping&quot;</span>, value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;admin:admin&quot;</span><span style="color: #009900;">&#41;</span>,
		@WebInitParam<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;resource-config&quot;</span>, value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/WEB-INF/config.xml&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleWebdavServlet <span style="color: #000000; font-weight: bold;">extends</span> org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">jackrabbit</span>.<span style="color: #006633;">webdav</span>.<span style="color: #006633;">simple</span>.<span style="color: #006633;">SimpleWebdavServlet</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	@EJB
	<span style="color: #000000; font-weight: bold;">private</span> RepositoryFactory repositoryFactory<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Repository</span> repository<span style="color: #339933;">;</span>
&nbsp;
	@PostConstruct
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> postConstruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		repository <span style="color: #339933;">=</span> repositoryFactory.<span style="color: #006633;">getRepository</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Repository</span> getRepository<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> repository<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Possible extended configuration of the repository:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- Store all items larger than 256 bytes in the FileDataStore --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DataStore</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.apache.jackrabbit.core.data.FileDataStore&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${rep.home}/repository/datastore&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;minRecordLength&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;256&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DataStore<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2010/04/jackrabbit-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some basic Glassfish commands</title>
		<link>http://famvdploeg.com/blog/2010/04/some-basic-glassfish-commands/</link>
		<comments>http://famvdploeg.com/blog/2010/04/some-basic-glassfish-commands/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 14:05:34 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=149</guid>
		<description><![CDATA[I ran out of brain capacity. So here is a list of commands to do some basic glassfish stuff. Updating: pkg image-update Start domain: asadmin start-domain Stop domain: asadmin stop-domain Deploy item: asadmin deploy &#60;path to file&#62; List JNDI entries: asadmin list-jndi-entries]]></description>
			<content:encoded><![CDATA[<p>I ran out of brain capacity. So here is a list of commands to do some basic glassfish stuff.</p>
<table>
<tr>
<td>Updating: </td>
<td>pkg image-update</td>
</tr>
<tr>
<td>Start domain: </td>
<td>asadmin start-domain</td>
</tr>
<tr>
<td>Stop domain: </td>
<td>asadmin stop-domain</td>
</tr>
<tr>
<td>Deploy item: </td>
<td>asadmin deploy &lt;path to file&gt;</td>
</tr>
<tr>
<td>List JNDI entries: </td>
<td>asadmin list-jndi-entries</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2010/04/some-basic-glassfish-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
