Wednesday, January 6, 2010

Creating AMPs In Alfresco To Change share UI .


Here I will explain How to create a AMP to change share login page UI.

Step.1 : Open Eclipse editor and Create a Java project. then it will create a default source folder. delete that folder.create the folders structure as shown below.


Step2: here build.xml and module.properties are two files. Create these two files

copy the below code and paste in buil.xml

---------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>

<project name="Sample Module" default="package-amp" basedir=".">

<property name="project.dir" value="."/>
<property file="${project.dir}/build.properties"/>
<property file="${project.dir}/module.properties"/>

<property name="build.dir" value="${project.dir}/build"/>
<property name="config.dir" value="${project.dir}/config"/>
<property name="jar.file" value="${build.dir}/lib/${module.id}.jar"/>
<property name="amp.file" value="${build.dir}/dist/${module.id}.amp"/>

<target name="mkdirs">
<mkdir dir="${build.dir}/dist" />
<mkdir dir="${build.dir}/lib" />
<mkdir dir="${build.dir}/classes" />
</target>

<path id="class.path">
<dirset dir="${build.dir}" />
<fileset dir="${project.dir}/lib" includes="**/*.jar" />
<fileset dir="${alfresco.sdk.dir}/lib/server" includes="**/*.jar" />
</path>

<target name="clean">
<delete dir="${build.dir}" />
</target>

<target name="compile" depends="mkdirs">
<javac classpathref="class.path" debug="${debug}" srcdir="${project.dir}/source/java"
destdir="${build.dir}/classes" target="1.5" encoding="UTF-8"/>
<copy todir="${build.dir}/classes">
<fileset dir="${project.dir}/source/java" defaultexcludes="false">
<exclude name="**/*.java"/>
<exclude name="**/.svn/**"/>
<exclude name="**/CVS/**"/>
</fileset>
</copy>
</target>

<target name="package-jar" depends="compile">
<jar destfile="${jar.file}" encoding="UTF-8">
<fileset dir="${build.dir}/classes" excludes="**/custom*,**/*Test*" defaultexcludes="false" />
</jar>
</target>

<target name="package-amp" depends="package-jar" description="Package the Module" >
<zip destfile="${amp.file}" encoding="UTF-8">
<fileset dir="${project.dir}/build" includes="lib/*.jar" />
<fileset dir="${project.dir}" includes="config/**/*.*" excludes="**/module.properties" />
<fileset dir="${project.dir}">
<include name="module.properties"/>
<include name="file-mapping.properties" />
<include name="WEB-INF/**/*" />
<include name="lib/**/*" />
<exclude name="WEB-INF/alfresco.tld"/>
<exclude name="WEB-INF/repo.tld"/>
</fileset>
<zipfileset dir="source/web" prefix="web"/>
</zip>
</target>
</project>
----------------------------------------------------------------------------------------------------------------

copy the below code and paste in module.properties
---------------------------------------------------------------------------------------------------
# SDK Share UI module
module.id=ShareUI
module.title=Share UI Project
module.description= Project to build an amp file for Share UI
module.version=1.0
----------------------------------------------------------------------------------------------------

Step3:
Here I am going to change Login page of share and share footer.
for this  changes we need to change following files


1.slingshot-login.ftl

2.alfresco-templte.ftl

3.footer.get.html.ftl

4.footer.get.properties

5.header.get.html.ftl

                       change the required images and text in above files and create a project structure as shown below. then right click on build.xml and run as ant build.

        finally you will get a amp file in the build path as shown below.




Step4:
                 Next step is copy these amp file and place into amps folder  in which you are alfresco installed.
then go to apply_amps.bat file. copy this file and rename it with  share_apply_amps.bat, copy the code below.

--------------------------------------------------------------------------------------------------------
@echo off
rem -------
rem Script for apply AMPs to installed WAR
rem -------

set ALF_HOME=%~dp0
set CATALINA_HOME=%ALF_HOME%tomcat

if not exist "%ALF_HOME%SetPaths.bat" goto getpaths
call "%ALF_HOME%SetPaths.bat"
goto start

:getpaths
call "%ALF_HOME%bin\RegPaths.exe"
call "%ALF_HOME%SetPaths.bat"
del "%ALF_HOME%SetPaths.bat"

:start
echo This script will apply all the AMPs in %ALF_HOME%amps to the share.war file in %CATALINA_HOME%\webapps
if ""%1"" == ""nowait"" goto nowait1
echo Press control-c to stop this script . . .
pause
:nowait1
"%JAVA_HOME%\bin\java" -jar "%ALF_HOME%bin\alfresco-mmt.jar" install "%ALF_HOME%amps" "%CATALINA_HOME%\webapps\share.war" -directory "%2"
"%JAVA_HOME%\bin\java" -jar "%ALF_HOME%bin\alfresco-mmt.jar" list "%CATALINA_HOME%\webapps\share.war"
echo .
echo About to clean out tomcat/webapps/share directory and temporary files...
if ""%1"" == ""nowait"" goto nowait2
pause
:nowait2
rmdir /S /Q "%CATALINA_HOME%\webapps\share"
call "%ALF_HOME%bin\clean_tomcat.bat"

-------------------------------------------------------------------------------------------------------------

save the above file and close it.

Step5: Double click on  share_apply_amps.bat a window will appear. as shown below.


Restart the tomcat server and check the changes you have made.that login page will be changed and  as well as footer and header.



For More info go to :


7 mistakes developers make when customizing Alfresco Share

6 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Doesnt work for me.
    It deploys the amp to the alfresco war.

    Alfresco 3.3 community.
    Ubuntu....

    In my apply_amps.sh file i have :

    java -jar bin/alfresco-mmt.jar install ./amps $CATALINA_HOME/webapps/alfresco.war -directory
    java -jar bin/alfresco-mmt.jar list $CATALINA_HOME/webapps/alfresco.war
    java -jar bin/alfresco-mmt.jar install ./amps-share $CATALINA_HOME/webapps/share.war -directory
    java -jar bin/alfresco-mmt.jar list $CATALINA_HOME/webapps/share.war

    Am i missing something ?

    ReplyDelete
  3. Its in the code.
    Make a new folder called amps-share.
    Drop your amps in there.

    Thats it.

    ReplyDelete
  4. Hey sorry guys., to apply the amp for alfresco place amp file in amps folder but where as to apply amp to share place the amp file by creating amps-share folder,and place in that.

    Thanks&Regards
    Chandu.

    ReplyDelete
  5. you can also., go through this article.

    http://aboutalfresco.blogspot.com/2010/04/creating-new-alfresco-module-to-change.html

    ReplyDelete
  6. Do you have the source code posted for this custom AMP?

    ReplyDelete