Tuesday, February 26, 2013

Generic printing of properties in complex javascript object

I needed to make a generic solution for printing ScriptNode and the like object to JSON using FreeMarker, without knowing which keys to include before the script runs ... So I wanted just to print all property like key and value pair (String/String).

Turns out this is a little cumbersome, so here is my 5 cents:

<#assign keys=item?keys>
<#assign values=item?values>
<#assign max=keys?size>
<#assign jsonIndex=0>
{

 <#list 0..max as index>
  <#if keys[index]?exists>
   <#if keys[index]?is_string>
    <#if values[index]?exists>
     <#if values[index]?is_string>
      <#if jsonIndex!=0>,

      <#else>
       <#assign jsonIndex=jsonIndex+1>
      </#if>
"${keys[index]}" : "${values[index]}"
     </#if>
    </#if>
   </#if>
  </#if>
 </#list>

}

Well, what does it do ... it keeps two different indexes, one for the key/value pair being processed and one for number of json lines added for adding commas. It seems FreeMarker cannot handle Hashes with non-strings, so to bypass this restriction you must index your way through and test for existens and for type being String. This is done over the keys and values sequences, which are read from item (Javascript object, which become a FreeMarker SimpleHash).

Friday, February 22, 2013

Easily make share the 'default' application in Tomcat

Normally you have a ROOT webapp in tomcat/webapps, which is a dummy Tomcat one.

To make this webapp redirect to i.e. alfresco share, when you type <server name>:<tomcat port> in your browser, but this in your tomcat/webapps/index.jsp file:

<%
response.sendRedirect("/share");
%>
 
If there is an index.html og index.htm file remove it.
 
Now index.jsp will redirect and you do not need to change the share-webapp 
 
Note: there is other ways using Tomcat context and stuff 

Saturday, February 16, 2013

Visio preview in Alfresco

Just tested Alfresco CE 4.2.c and Libreoffice 4.0 release, and looking through the release notes, saw that it had much improve Visio support (improved libvisio) ...

Well uploaded some samples from M$ and they all renders fine in thumbnail and preview PDF :)


Alfresco uses PDF.js viewer and Libreoffice 4.0


Libreoffice 4 release notes: https://www.libreoffice.org/download/4-0-new-features-and-fixes#Filters

Please not some older star office and MS office formats are no longer supported!

I tried use 'soffice.bin' instead of 'soffice' as program in alfresco-global.properties, this had the effect on my installation, that oosplash process is not started!

Friday, February 1, 2013

Alfresco webscript description file schema ...

I was mocking about and decided to test reverse engineering the Alfresco / Spring framework Webscript description file schema ...

https://code.google.com/p/alfresco-webscript-schema/

Beware this contains alot of features and some are probable coupled to the webscript kind (attribute) :)

Another schema by SURF - eclipse plugin: https://anonsvn.springframework.org/svn/se-surf/trunk/spring-surf-devtools/spring-surf-eclipse-extensions/spring-surf-webscript-editor/schemas/DescriptionXMLSchema.xsd