Tuesday, April 1, 2014

Upgrading postgresql database from Alfresco installer

I had the pleasure to battle a little with postgresql installed by Alfresco installers. What I found out is that Alfresco tends to change the software; mainly the location of files, scripts and used libraries ... they probably have good reasons to do this, to ensure consistency across installations, but this makes it hard to follow standard software procedures ...

For the postgresql installation, what you need to know is that the original postgresql binary are renamed/postfixed with '.bin', EX: pg_ctl -> pg_ctl.bin ... and a new script file has been added called pg_ctl, which calles the original and ensures its environment.

After using some time on that, I found two ways to tackle that:
 - pg_upgrade, which needs clean version, so compile clean versions corresponding to the new and old postgresqls following this guide, using http://www.openscg.com/2013/04/how-to-compile-postgresql-9-2-x-from-source-on-ubuntu-12-x/ - however setting different prefixes in configure, EX: --prefix /usr/local/postgresql-9.2.4

 - use the guide here https://www.fossoffice.com/blog/2012/12/13/alfresco-community-4-0-e-to-4-2-c-upgrade-procedure/ - I skipped the lucene part switch

I ended up doing the latter, because i ran into the xlog problems with a seemingly dirty db, like: http://www.brentmc79.com/posts/psql-could-not-connect-oh-fuck-you


Wednesday, February 26, 2014

Monkey patching Alfresco Repo JS webscript

While Alfresco Share is now has many methods of overloading, overriding, changing, adding, removing functionality. Alfresco Repository have few, and a common pattern for larger solution is to replace existing files fully overriding functionality. While this works it is hard to maintain.

1) Replace file by overriding, hard to maintain, 'cannot' be undone
2) Override URL, by making your own Webscript and specifying the same URL, this is better, but require files, and it does not work for *.lib.js files
 - for *.lib.js (imported files), you can override all the webscripts that use that lib-file, and in the overload import your own, thus no file is overridden ... but for some lib-files this means too much work for the gain

3) Change Share/Frontend code to use a different Repo-webscript (your own), then provide you own webscript. This can in many cases be done with share-configuration.


Future will probably improve this:
http://blogs.alfresco.com/wp/developer/2012/05/23/webscript-extensibility-on-the-alfresco-repository/

With approach 2 & 3 you will still have the original JS code in the Alfresco webapp, and this fact can be used to monkey-path the file, minimizing the amount of code to-be-written, increase reuse and maintainability.

Example, standard Repo webscript pattern:

A.get.js

<#import ../B.lib.js >

function C() { ... };

function main() { ... };

main();


Monkey- patch file:

D.get.js

<#import /full-path-to-A/A.lib.js >

function C() { .... monkey-patch-with-your-code... };


Now D.get.js will have the same functionality as A.get.js, but with your change ...


BUT the resulting file will have two C-functions! Yes, but javascript only runs the last declared ... so it works.

In the Javascrip debugger:



D.get.js - @runtime


<#import ../B.lib.js >

function C() { ... };

function main() { ... };

main();

function C() { .... monkey-patch-with-your-code... };


See this discussion: http://stackoverflow.com/questions/15810249/which-and-how-javascript-function-will-be-called-if-we-have-2-function-declarati

Friday, January 10, 2014

Alfresco Share project - Maven setup with Java code

If you need a Alfresco Share - Maven pom with support for java code (ex. BaseEvaluators) ... You need this workaround for Alfresco Enterprise 4.2.0 in your <dependencies>:
 
<dependencies>
       <dependency>
            <groupId>${alfresco.groupId}</groupId>
             <artifactId>alfresco-share</artifactId>
            <version>${alfresco.version}</version>
            <scope>provided</scope>
            <exclusions>
               <exclusion>
                  <groupId>${alfresco.groupId}</groupId>
                  <artifactId>alfresco-web-framework-commons</artifactId>
              </exclusion>
           </exclusions>
        </dependency>
        <dependency>
        <!-- work around for error in POM, should be fixed in 4.2.1
        https://issues.alfresco.com/jira/browse/MNT-10118 -->
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-web-framework-commons</artifactId>
            <version>${alfresco.version}</version>
            <scope>system</scope>
            <systemPath>${tomcat.home}/webapps/share/WEB-INF/lib/alfresco-web-framework-commons-${alfresco.version}.jar</systemPath>
        </dependency>

...
  </dependencies>


and now you can start coding!

Tuesday, October 15, 2013

Mule - piggybacking SOAP calls in flows

I needed to handle session Cookie between connection calls and later data calls all in SOAP. I did this by using the same global HTTP connector with cookie enabled and using it on all the endpoints.

The connection call was in the first flow which then called the next ... that solves the Session handling without any coding, but i got mimetype/transformer exception on the 'return' / response path.

Errors like:
Could not find a transformer to transform "SimpleDataType{type=org.apache.cxf.staxutils.DepthXMLStreamReader, mimeType='text/xml'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}".

The easy solution turned out to be saving the first SOAP response, calling the data flows with their own SOAP, and after the flow call, restoring the SOAP response.

...
<set-variable variableName="connectionUpPayload" value="#[message.payload]" doc:name="save response"/>
<flow-ref name="GetAllProperties" doc:name="GetAllProperties"/>
<set-payload value="#[flowVars['connectionUpPayload']]" doc:name="Set Payload"/>

...

Wednesday, October 9, 2013

Mule - Sharepoint Connector

I have been working a little with Mule ESB - Enterprise Edition. I needed to get a Sharepoint (duh - Imperial Star Battlecruisers), so I was happy to see the Mule Sharepoint Connector. The Connector implementents NTLMv2, so it can talk to newer Sharepoint versions. After getting past the first small gotchas (remember slash af URL, URL without the '_vti_bin' stuff, ListName is the list name & view name is the GUID) - the list was received as an SOAP Java object - GetListItemsResult.

Now that was perfect except the M$ SOAP service limits the result to 100 rows, if you do not specify a rowlimit, and i could not get that to work on the Sharepoint Connector component, so i 'just' made a java component from trial and error reverse engineering the component using the Java classes:

import org.mule.modules.sharepoint.SharepointConnector;
import org.mule.modules.sharepoint.microsoft.lists.GetListItems;
import org.mule.modules.sharepoint.microsoft.lists.GetListItemsResponse.GetListItemsResult;

....
SharepointConnector sc = new org.mule.modules.sharepoint.SharepointConnector();
             sc.connect("DOMAIN\\USERNAME", "PASSWORD", "URL_W_SLASH");

org.mule.modules.sharepoint.microsoft.lists.GetListItems request =
            new org.mule.modules.sharepoint.microsoft.lists.GetListItems();
request.setListName("LISTNAME");
request.setRowLimit("" + 0);
request.setViewName("VIEW_GUID");
GetListItemsResult result = sc.listGetListItems(request);


Replace UPPERCASE names with real values. You can use the GetListAndView to get the GUIDs

Other ways of getting this to work is http://dmdaa.wordpress.com/2012/10/10/ntlm-v2-support-for-java-web-service-clients-wsimport-or-axis2-stubs-for-sharepoint-server/

However I did not succeed with that approach.

Thursday, September 12, 2013

Upgraded to Alfresco 4.2.d and lost your application menu bar ...

It might be because of an share-config override like:

  <config evaluator="string-compare" condition="WebFramework" replace="true">

Try removing replace="true" and if you need to replace, your should look up surf.xml to add all the new definitions.

Wednesday, September 4, 2013

Preview, index, thumbnail SVG in Alfresco

In modern browsers SVG is directly supported, so previewing is a smaller task. Ne add-on for Alfresco with enhanced SVG support for previewing, thumbnailing and indexing (search)


See more:
https://addons.alfresco.com/addons/enhanced-svg-support
http://code.google.com/p/alfresco-svg/