Search This Blog

About Me

Highly experienced in implementation and customization of Alfresco. More than 11 years of experience working on Alfresco, versions ranging from 2.x to 5.x. Successfully processed innovative and tailored CMS solutions to meet ever-changing business requirements for multiple clients. Role Includes : Experience in Alfresco Upgrades, SOLR migration, Proposals, Team Handling, Delivery, Content Migration, POC's etc.. Extensive experience in client co ordination, working on offshore-onshore model and project take over. Technical Expertise Includes : Java, JSP, Servlet, JSF, JavaScript, AJAX, Spring, SQL, Hibernate, Web Services(REST). Specialities Includes : Content Migration, Product Customization, Business CMS Solutions, Workflow, Project Transition.

Monday, January 16, 2017

Setting Up Maven Proxy

When you are working behind a firewall, you can get connection refused error while downloading dependencies from maven repository.

You can fix it by setting up proxy in your maven's settings.xml

1. Open your maven installation directory.
2. Go to conf/settings.xml
3. Look for <proxies> tag.
4. Add below proxy profile

 <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>YOUR DOMAIN USERNAME</username>
      <password>ACTUAL PASSWORD</password>
      <host>PROXY YOU ARE WORKING BEHIND</host> <!-- You can get this from internet explorer                                                                                                       - internet options - connections - LAN                                                                                                            settings -->
      <port>PROXY PORT (Can get same from above)</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
 </proxy> 


5. Save settings.xml
6. Try downloading dependencies again.

Setting up Git Proxy

Sometimes you keep working behind firewall which can block your access to git repository.
In order to download git project/modules, you might need to set up proxy so that it can connect to github crossing firewall.

You can use below command in git bash console and try to clone the project.


##Setting Git Proxy###

$ git config --global http.proxy http://<PASSWORD>@<PROXY NAME>:<PROXY PORT>

Alfresco Development Environment - Community Version 5.0.0



Alfresco provides archetype for quick set up of development environment.You can follow below steps for setting up development environment in eclipse.

# Pre Requisite

1. Maven 3.x and 2.x

2. Java 7 +

3. Eclipse


1. Create a folder.

2. Open command prompt.

3. Navigate to folder you have created.

4. Generate a maven project (archeType) using below command with Maven 2.1 as 3.x doesn't generate interactive mode. You can set Maven 3.x in path again after archetype generation.

mvn archetype:generate -Dfilter=org.alfresco:

this will generate interactive mode and you will get options to download sdk's depending on your requirement.

5. Select all in one option . This will download all sdk's/projects (alfresco, share etc). You can work independently on them.

6. Now select archetype version, this is aligned to alfresco build versions.

    You can verify alfresco versions against sdk's here.

7. Provide group id (kind of package name), artifact id (project name) and version (set this to default, unless you know about any specific version)

8. Now you will see folders generated with pom's. These are alfresco projects for development.

9. For adding these projects into eclipse follow belo steps.

a. Open eclipse workspace.

b. In project explorer, right click and select import.

c. Select existing maven project.

d. Navigate to folder you had created above.

e. Select all alfresco downloaded projects and import them.

f. Your projects are ready for development.

10. Building project and generating war

a. Open command prompt.

b. Navigate to project (repo/share).

c. Type mvn package.

d. Wait for sometime, a war will be generated under target folder.

e. You can copy generated war under tomcat instance by renaming from repo to alfresco.

11. Some more useful maven commands for alfresco


Command                           Description


mvn package                        Runs unit tests and packages AMP in ${project.build.directory}                                                                   /${project.build.finalName}.amp


mvn install                            Like mvn package but also installs AMP in local Maven repository
                                            to be depended upon

mvn test                                Runs unit tests

mvn install -DskipTests=true  Like mvn install but skips unit tests

mvn install -Prun                    Like mvn install but also triggers the runner project to run

Alfresco, Share, Solr and Web Quick Start in Tomcat (with H2 embedded database)


mvn clean -Ppurge                 Removes DB, alf_data, indexes and log files. Useful to purge the development                                              repo (by default self contained in ${project.basedir}/alf_data_dev.

Note:
This is an important command to use if you change significant settings in your project - for example you change the Alfresco edition from Community to Enterprise. It is important to purge databases and other
data that might otherwise be persisted.

mvn install -Pamp-to-war,rad   Similar to mvn install -Pamp-to-war but also adds support for remote

JUnit running and for hot reloading with JRebel (requires appropriate MAVEN_OPTS configuration).

Alfresco Development Environment Set Up - Community Version 4.2.e

Alfresco provides archetype for quick set up of development environment.

You can follow below steps for setting up development environment in eclipse.

# Pre Requisite

1. Maven 3.x
2. Java 7 +
3. Eclipse

1. Create a folder.
2. Open command prompt.
3. Navigate to folder you have created.
4. Generate a maven project (archeType) using below command

mvn archetype:generate -DarchetypeCatalog=http://artifacts.alfresco.com/nexus/content/groups/public/archetype-catalog.xml -Dfilter=org.alfresco.maven.archetype:

this will generate interactive mode and you will get options to download sdk's depending on your requirement.

5. Select all in one option . This will download all sdk's/projects (alfresco, share etc). You can work independently on them.

6. Now select archetype version, this is aligned to alfresco build versions.

You can verify alfresco versions against sdk's here.

7. Provide group id (kind of package name), artifact id (project name) and version (set this to default, unless you know about any specific version)

8. Now you will see folders generated with pom's. These are alfresco projects for development.

9. For adding these projects into eclipse follow below steps.

a. Open eclipse workspace.
b. In project explorer, right click and select import.
c. Select existing maven project.
d. Navigate to folder you had created above.
e. Select all alfresco downloaded projects and import them.
f. Your projects are ready for development.

10. Building project and generating war with custom code.

a. Open command prompt.
b. Navigate to project you want to build and generate war.
c. Type mvn package.
d. Wait for sometime, a war will be generated in project target folder.
 e.  You can copy generated war under tomcat instance.

11. Some more useful maven commands for alfresco

Command Description
mvn package Runs unit tests and packages AMP in ${project.build.directory}
/${project.build.finalName}.amp
mvn install Like mvn package but also installs AMP in local Maven repository
to be depended upon
mvn test Runs unit tests
mvn install -DskipTests=true Like mvn install but skips unit tests
mvn install -Prun Like mvn install but also triggers the runner project to run
Alfresco, Share, Solr and Web Quick Start in Tomcat
(with H2 embedded database)
mvn clean -Ppurge Removes DB, alf_data, indexes and log files. Useful to purge
the development repo (by default self contained in
${project.basedir}/alf_data_dev.


Note:

This is an important command to use if you change significant settings in your project - for example you change the Alfresco edition from Community to Enterprise. It is important to purge databases and other
data that might otherwise be persisted.
mvn install -Pamp-to-war,rad Similar to mvn install -Pamp-to-war but also adds support for remote
JUnit running and for hot reloading with JRebel (requires appropriate MAVEN_OPTS configuration).


Wednesday, June 30, 2010

Code to apply Template using Alfresco Web Service Client


Below is a small code for applying a template to a content using web service API

Note – For applying a template, you need to set the template node ref as a template property

I have taken reference of alfresco out of the box document template.



Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
String rootHome="/app:company_home";
String filename = "test.txt";
String templateID = "workspace://SpacesStore/a4d6ab23-989a-46c6-9c13-3ea2be97d208";
ParentReference contentReference = new ParentReference(storeRef, null, rootHome, Constants.ASSOC_CONTAINS, filename);
     contentReference.setChildName("cm:" + filename);
     NamedValue[] properties = new NamedValue[]
     {
             Utils.createNamedValue(Constants.PROP_NAME, filename),
             Utils.createNamedValue(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "template"), templateID)
     };
     create = new CMLCreate("1", contentReference, null, null,null, Constants.TYPE_CONTENT, properties);
     cml = new CML();
     cml.setCreate(new CMLCreate[] { create }); // Content Created
     result = WebServiceFactory.getRepositoryService().update(cml);

Thursday, April 22, 2010

Running Alfresco Community 3.2 First Foundation Client SDK

  1. Set up Tomcat bundled Alfresco alfresco-community-tomcat-3.2 on your local machine.

    You can download it here. Start it once before you run first foundation client.

  2. Download alfresco-community-sdk-3.2 from here.
  3. Open your eclipse, import alfresco-community-sdk-3.2.zip.
  4. Select projects Alfresco Embedded, SDK First Foundation Client
  5. Click on Finish
  6. Provide dir.root, db.username, db.password, db.driver, db.url into custom-repository.properties present in SDK Project.
  7. Add all the jars present in "\alfresco-community-tomcat-3.2\tomcat\webapps\alfresco\WEB-INF\lib" to your SDK project's build path
  8. Also add your respective database driver and servlet jar file as it's not provided into the lib.
  9. Now build the SDK project
  10. Make sure your tomcat is not running, if yes, shut it down. I do not know why but it is generating JVM Bind error when we run FFC with tomcat server running.
  11. Run First Foundation Client.

I hope you will not face any issues running it.

After it's been run successfully, start your tomcat, you will see a new file created in company home space.

Thursday, April 15, 2010

Overriding the default update action of alfresco



Alfresco's default update action just replaces the contents of the document without changing its name and other properties.

 
This blog deals with overriding the default update action with your customized one.

 
As update action consists of a dialog in which you needs to browse and select a new document from your local machine, a new upload jsp file needs to be written which will take care of the upload part and will perform the function which you have over ridden.

 
If you want to add a dialog on the action you provide, then you have to register it into 'web-client-config-dialogs-custom.xml' (here after we will mention it as 'dialogs-custom.xml')

Like, if you want to display your custom view details page on clicking of view details link action, you can define it here with bean reference for that particular jsp.

 
Suppose if you have defined your custom update link action on clicking which, you want your custom update jsp page should appear, you can define it here like –

 
[Note – I am just providing the update action and its dialog here, rest you can change as per the steps I have mentioned here]



Actions Tag in actions-custom.xml

 
<!-- Update document -->

     <action id="update_doc">

     <permissions>

     <permission allow="true">Write</permission>

     </permissions>

     <evaluator>org.alfresco.web.action.evaluator.UpdateDocEvaluator</evaluator>

     <label-id>update</label-id>

     <image>/images/icons/update.gif</image>

     <action-listener>#{CheckinCheckoutDialog.setupContentAction}</action-listener>

     <action>dialog:updateFile</action> <!-- Dialog Name -->    

<params>
     <param name="id">#{actionContext.id}</param>

     </params>

    </action>


  <!-- Dialog Tag in dialogs.xml -->   

 
<dialog name="updateFile" page="/jsp/extension/custom-update-file.jsp" managed-

bean="UpdateFileDialog" icon="/images/icons/update_large.gif" title-id="update"

        description-id="updatefile_description"/>

 
Now when you use customized update action link, your custom update jsp file will appear with update button.

When you select the file from your local system and click on update, your overridden method will get called.

 
Here is the class file with overridden Update method.

 
Do not forget to register your bean into faces-config-custom.xml

 
<managed-bean>
<description>The bean for the Update File Screen.</description>
<managed-bean-name> UpdateFileDialog</managed-bean-name>
<managed-bean-class>
com.test.update.UpdateFileDialog
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>property</property-name>
<value>#{CCProperties}</value>
</managed-property>
</managed-bean>