Saturday, 12 October 2013

Alfresco Remote debugging in Eclipse (Windows)

1.  Open command prompt window (Start –> Run –> cmd). If you do note have administrator permission then create shortcut of cmd.exe and run this as a Administrator.
2.  Go to “tomcat\bin” folder (e.g. cd c:\alfresco\tomcat\bin).
3.  Enter the command tomcat6w.exe //ES//alfrescoTomcat which launches the service configuration dialog box. 
4. Click on the JAVA tab and enter the following text at the bottom of the “Java Options” field as per the below screenshot (note that that line break is significant):

Alfresco service dialog box.
5.  Close the dialog box and restart alfresco.

Eclipse setting.
1.      Open Eclipse.
2.  Select “Debug Configurations…” from the “Run” pull-down menu.
3.  Double-click “Remote Java Application” to create a “New_configuration” profile.
4.  On the “Connect” tab, browse to the project you want to debug.
5.  Change the “Port” in “Connection Properties” to 8000(or any not used).
6.  Leave all the rest at the defaults and click the “Debug” button to start debugging!

      Happy Coding.

Wednesday, 9 October 2013

Create Custom Alfreco Content Types Step by Step

There are few out of the box content models are available which can be used to design the custom content types.


All these models are placed in WEB-INF\classes\alfresco\model.

Create Sample Custom Model

Hope development environment and Alfresco 4.x already in place. We can use two approaches for building the alfresco custom application. One using the war file creation and other is amp creation. It depends on the requirement which is applicable for you.

For custom content model need to follow below steps
1)      Create directory structure
2)      Create a model file
3)      Create custom model context file
4)      Create property file for resource bundle
5)      Create custom web-client-config
6)      Build war or amp
7)      Deploy in tomcat and Restart

Create Directory structure

I would suggest to follow the following the directory structure which is easy to maintain for  large scale development.

      Create a model file

Create content model file sampleContentModel.xml in /src/main/config/model.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="ss:contentmodel" xmlns="">
       <!-- Optional meta-data about the model -->
       <description>Sample Content Model</description>
       <author>Saket S</author>

              <!-- Import Alfresco Dictionary Definitions -->
              <import uri=""
                     prefix="d" />
              <!-- Import Alfresco Content Domain Model Definitions -->
              <import uri="" prefix="cm" />
              <import uri="" prefix="bpm" />

              <namespace uri=""
                     prefix="ss" />

              <type name="ss:sampleFolder">
                     <title>Sample Folder</title>
              <type name="ss:sampleContent">
                     <title>Sample Content</title>
                           <property name="ss:name">

In above code
  • <parent> is a type of content which could be file or folder or custom. 
  • <namespace> uri could be anything with proper format. Version plays very important role and it should be incremental for major changes.

Create custom model context file

For context file either you can create custom context file or make an entry in existing module-context.xml file. Depends on complexity of application you can make the decision.
For this example will create the custom context file sample-bootstrap-context.xml in /src/main/config/context/ folder.


<bean id="extensioniop.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
              <property name="models">
              <property name="labels">
       <bean id="sample_alfresco_module.resourceBundlesWebApp" class="">
              <property name="resourceBundles">

In above code {artifactId} is module id which mentioned in the pom file. So whenever this code deploys in alfresco it resides in Module folder with the {artifactId} value.

Create property file for resource bundle

Create property file in /src/main/config/messages.

sample-folder=Sample Folder

 Create custom web-client-config

 In web-clinet-config file add the following lines in particular sections

       <config evaluator="node-type" condition="ss:sampleContent">
                     <show-property name="ss:name"
                           display-label-id="name" />
       <config evaluator="string-compare" condition="Content Wizards">
                     <type name="ss:sampleContent" />

       <config evaluator="node-type" condition="ss:sampleFolder">
       <!-- To add in custom Space Types -->
       <config evaluator="string-compare" condition="Space Wizards">
                 <type name="ss:sampleFolder" description="Sample Folder" 
                 display- label="Sample Folder" />

       <config evaluator="string-compare" condition="Action Wizards">
              <type name="ss:sampleFolder" display-label-id="sample-folder" />
       <config evaluator="string-compare" condition="Advanced Search">
              <type name="ss:sampleFolder" display-label-id="sample-folder" />

Build war or amp

Time to build the war or amp file using maven or ant. Verify the logs if any error.

      Deploy in tomcat and Restart

Deploy the war in tomcat and restart the server.

 Login to alfresco and verify the sample code. You should be able to see the custom content type and folder


Happy Coding.