<?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>Mi espacio &#187; api</title>
	<atom:link href="http://www.manuelrecena.com/blog/archives/tag/api/feed" rel="self" type="application/rss+xml" />
	<link>http://www.manuelrecena.com/blog</link>
	<description>Donde escribo sobre cosas que forman parte de mi vida profesional</description>
	<lastBuildDate>Sun, 05 Feb 2012 21:20:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Comprobar que Alfresco REST API está disponible</title>
		<link>http://www.manuelrecena.com/blog/archives/842</link>
		<comments>http://www.manuelrecena.com/blog/archives/842#comments</comments>
		<pubDate>Thu, 12 Nov 2009 11:47:21 +0000</pubDate>
		<dc:creator>Manuel Jesús Recena Soto</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[alfresco]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.manuelrecena.com/blog/?p=842</guid>
		<description><![CDATA[Para el plugin de Trac que estoy desarrollando (en los huecos que tengo) estoy desarrollando un pequeño cliente en python que me permita trabajar cómodamente con Alfresco REST API, especialmente con CMIS Web Reference. Uno de los métodos que necesitaba para este cliente es aquel que me permitiese comprobar si la configuración para trabajar con [...]]]></description>
			<content:encoded><![CDATA[<p>Para el <a title="Referencia a una entrada de este blog" href="http://www.manuelrecena.com/blog/archives/803" target="_blank">plugin de Trac</a> que estoy desarrollando (en los huecos que tengo) estoy desarrollando un <a title="Acceso al código fuente del plugin" href="http://trac.ebabel.info/projects/alfrescointegration/browser/trunk/alfrescointegration/alfresco_backend.py" target="_blank">pequeño cliente</a> en python que me permita trabajar cómodamente con <a title="Referencia a la documentación de Alfresco sobre su RESTful API" href="http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference" target="_blank">Alfresco REST API</a>, especialmente con <a title="Referencia a la documentación de Alfresco sobre su RESTful API (CMIS Web Reference)" href="http://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference" target="_blank">CMIS Web Reference</a>. Uno de los métodos que necesitaba para este cliente es aquel que me permitiese comprobar si la configuración para trabajar con el API era correcta. Comprobar eso lleva implícito comprobar que Alfresco está disponible (se tiene acceso HTTP).</p>
<p>La configuración del plugin en relación a Alfresco es muy simple:</p>
<ul>
<li>Usuario y contraseña (credenciales)</li>
<li>URL base en la que se publica RESTful API</li>
</ul>
<p>Dejo por aquí el fragmento de código:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> is_alive<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    isAlive_service = <span style="color: #008000;">self</span>.__url_api + <span style="color: #483d8b;">'/login'</span> +  <span style="color: #483d8b;">'?u=dummy&amp;amp;pw=dummy'</span>
    <span style="color: #008000;">self</span>.__log.<span style="color: black;">debug</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Restful Service: '</span> + isAlive_service<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        response, content = <span style="color: #008000;">self</span>.__http.<span style="color: black;">request</span><span style="color: black;">&#40;</span>isAlive_service, <span style="color: #483d8b;">'GET'</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> response.<span style="color: black;">status</span> == <span style="color: #dc143c;">httplib</span>.<span style="color: black;">FORBIDDEN</span>:
            <span style="color: #008000;">self</span>.__log.<span style="color: black;">debug</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Alfresco RESTful API is alive'</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #008000;">self</span>.__log.<span style="color: black;">debug</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Alfresco RESTful API is not alive'</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span>
    <span style="color: #ff7700;font-weight:bold;">except</span>:
        <span style="color: #008000;">self</span>.__log.<span style="color: black;">debug</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Alfresco RESTful API is not alive'</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span></pre></div></div>

<p>Cualquier sugerencia será bienvenida.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manuelrecena.com/blog/archives/842/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

