Wednesday, April 28, 2010

Code to Hide Actions in Alfresco

Here i added code to hide delete option on space and document in alfresco, add the following code in web-client-config-custom.xml

<config>
<actions>
<action-group id="space_browse">
<show-link>false</show-link>
<action idref="delete_space" hide="true" />
</action-group>

<action-group id="browse_actions_menu">
<show-link>false</show-link>
<action idref="delete_space" hide="true" />
</action-group>


<action-group id="doc_details_actions">
<action idref="delete_doc" hide="true" />
</action-group>


<action-group id="space_details_actions">
<action idref="delete_space" hide="true" />
</action-group>

<action-group id="document_browse">
<show-link>false</show-link>
<action idref="delete_doc" hide="true" />
</action-group>

<action-group id="document_browse_menu">
<action idref="delete_space" hide="true" />
</action-group>

<action-group id="space_browse_menu">
<action idref="delete_space" hide="true" />
</action-group>

</actions>
</config>



Here i added code to hide copy & cut  options on space and document in alfresco, add the following code in web-client-config-custom.xml

<config>
<actions>
<action-group id="space_browse">
<show-link>false</show-link>
<action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" />
</action-group>

<action-group id="browse_actions_menu">
<show-link>false</show-link>
<action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" />
</action-group>

<action-group id="doc_details_actions">
<action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" />
</action-group>

<action-group id="space_details_actions">
<action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" />
</action-group>

<action-group id="document_browse">
<show-link>false</show-link>
<action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" />
</action-group>

<action-group id="document_browse_menu">
<action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" />
</action-group>

<action-group id="space_browse_menu">
<action idref="cut_node" hide="true" />
<action idref="copy_node" hide="true" />
</action-group>
</actions>
</config>

Monday, April 19, 2010

Alfresco Outlook configuration for IMAP

Follow these steps to configure outlook send mail to alfresco

step1:  go to  C:\Windows\System32\drivers\etc

here add  server name. just for testing i  added chandu.com as follows

127.0.0.1 chandu.com

Step2:  next open Microsoft outlook ., select  tools > account settings.

click on new ... it will open a wind follow some steps to add a new account

a.select Microsoft POP3,IMAP, HTTP.... click next
b. select manually configure server settings...... click next
c.select internet Email
d.fill the details as follows
----------------------------------------------------------------------------------
         your name                  :             pradeep
         EmailAdd                   :             pradeep@chandu.com
  Server Information
         Account Type             :            IMAP
         Incoming mail Ser        :           chandu.com
         Outgoing Mail ser        :           chandu.com
Logon Information
         username                    :            pradeep
         password                    :            *********
-----------------------------------------------------------------------------------

Click on next and finish.

Step3: all the above configuration is in outlook now., just  login to alfresco go to Administration Console
Click on Manage system users --> create user

then fill the new wizard details., make sure that  email id is pradeep@chandu.com


just finish that wizard.

Step4:  then go to company home and create one space., name it as you like., here i am creating the space with the name mycompany.
      click on mycompany -- > view details --> manage space users --> invite user.
search for the user pradeep and add that user as contributor or what ever that you want but make sure about permissions, 


Step5: go to mycompany space and go to view details and click on run action ., it will open run action wizard
select add aspect  and click on set values and add,  select Email Alias , then click on next  and finish that wizard.
 next edit this space property., and create Email Alias as some companyadmin




Step6: go to   \tomcat\shared\classes\alfresco\extension

unzip the custom-email-server.sample.zip file and change  custom-email-server.properties as follows


# Email Server properties
email.server.enabled=true
email.server.port=25
email.server.domain=chandu.com

Step7: go to  \tomcat\shared\classes  ---- > alfresco-global.properties uncomment these lines.


# IMAP
#-------------
imap.server.enabled=true
imap.server.port=143
imap.server.host=localhost


Step8: restart the server and go to outlook to compose a mail ., with to address as companyadmin@chandu.com.
 you will get mail as document in mycompany space. and also you can find the alfresco folders in outlook.


here some information is available and also screen shots also .

http://wiki.alfresco.com/wiki/IMAP


  

Creating a new Alfresco module to change the Alfresco Footer.

Hi., Here I am going to explain about to change the default footer of alfresco.

follow the below steps .

Step1: Create java project with  the structure as shown below in eclipse



Step2: Import the Alfresco related files to change the UI of it.suppose here i want to change  login page and the footer of the alfresco so., lets start to import the files to alfresco as shown below with below structure.

Step3: copy the below code for build.xml file.

<?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/**/*" />
<exclude name="WEB-INF/alfresco.tld" />
<exclude name="WEB-INF/repo.tld" />
</fileset>
<zipfileset dir="source/web" prefix="web" />
</zip>
</target>
</project>

Step4: for pagetag.java., copy the below code ., and change the code as follows., which is high lated in red color.
-------------------------------------------------------------------------------------------------------------

 /*
* Copyright (C) 2005-2010 Alfresco Software Limited.
 *
 * This file is part of Alfresco
 *
 * Alfresco is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Alfresco is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Alfresco. If not, see .
 */
package org.alfresco.web.ui.repo.tag;

import java.io.IOException;
import java.io.Writer;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.coci.CCProperties;
import org.alfresco.web.config.ClientConfigElement;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * A non-JSF tag library that adds the HTML begin and end tags if running in servlet mode
 * 
 * @author gavinc
 */
public class PageTag extends TagSupport
{
   private static final long serialVersionUID = 8142765393181557228L;
   
   private final static String SCRIPTS_START = "\n";
   private final static String STYLES_START  = "\n";

   private final static String[] SCRIPTS = 
   {
      // menu javascript
      "/scripts/menu.js",
      // webdav javascript
      "/scripts/webdav.js",
      // base yahoo file
      "/scripts/ajax/yahoo/yahoo/yahoo-min.js",
      // io handling (AJAX)
      "/scripts/ajax/yahoo/connection/connection-min.js",
      // event handling
      "/scripts/ajax/yahoo/event/event-min.js",
      // mootools
      "/scripts/ajax/mootools.v1.11.js",
      // common Alfresco util methods
      "/scripts/ajax/common.js",
      // pop-up panel helper objects
      "/scripts/ajax/summary-info.js",
      // ajax pickers
      "/scripts/ajax/picker.js",
      "/scripts/ajax/tagger.js"
   };
   
   private final static String[] CSS = 
   {
      "/css/main.css",
      "/css/picker.css"
   };

/**
 * Please ensure you understand the terms of the license before changing the contents of this file.
 */
   
   private final static String ALF_LOGO_HTTP  = "http://www.alfresco.com/assets/images/logos/community-edition-3.3.png";
   private final static String ALF_LOGO_HTTPS = "https://www.alfresco.com/assets/images/logos/community-edition-3.3.png";
   private final static String ALF_URL   = "http://www.alfresco.com";
   private final static String ALF_TEXT  = "Alfresco Community";
   private final static String ALF_COPY  = "Supplied free of charge with " +
        "no support, " +
        "no certification, " +
        "no maintenance, " +
        "no warranty and " +
        "no indemnity by " +
        "Alfresco or its " +
        "Certified Partners. " +
        "Click here for support. " +
        "Alfresco Software Inc. © 2005-2010 All rights reserved.";
   
   private final static Log logger = LogFactory.getLog(PageTag.class);
   private static String alfresco = null;
   private static String loginPage = null;
   
   private long startTime = 0;
   private String title;
   private String titleId;
   private String doctypeRootElement;
   private String doctypePublic;
   private String doctypeSystem;
   
   /**
    * @return The title for the page
    */
   public String getTitle()
   {
      return title;
   }

   /**
    * @param title Sets the page title
    */
   public void setTitle(String title)
   {
      this.title = title;
   }
   
   /**
    * @return The title message Id for the page
    */
   public String getTitleId()
   {
      return titleId;
   }

   /**
    * @param titleId Sets the page title message Id
    */
   public void setTitleId(String titleId)
   {
      this.titleId = titleId;
   }

   public String getDoctypeRootElement()
   {
      return this.doctypeRootElement;
   }

   public void setDoctypeRootElement(final String doctypeRootElement)
   {
      this.doctypeRootElement = doctypeRootElement;
   }
   
   public String getDoctypePublic()
   {
      return this.doctypePublic;
   }

   public void setDoctypePublic(final String doctypePublic)
   {
      this.doctypePublic = doctypePublic;
   }

   public String getDoctypeSystem()
   {
      return this.doctypeSystem;
   }
   
   public void setDoctypeSystem(final String doctypeSystem)
   {
      this.doctypeSystem = doctypeSystem;
   }
   
   public void release()
   {
      super.release();
      this.title = null;
      this.titleId = null;
      this.doctypeRootElement = null;
      this.doctypeSystem = null;
      this.doctypePublic = null;
   }

   /**
    * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
    */
   public int doStartTag() throws JspException
   {
      if (logger.isDebugEnabled())
         startTime = System.currentTimeMillis();
      
      try
      {
         String reqPath = ((HttpServletRequest)pageContext.getRequest()).getContextPath();
         Writer out = pageContext.getOut();
         
         if (!Application.inPortalServer())
         {
            if (this.getDoctypeRootElement() != null &&
                this.getDoctypePublic() != null)
            {
               out.write("\n");
            }
            else
            {
               out.write("\n");
            }
            out.write("\n");
            out.write("\n");
            out.write("\n");
            out.write("\n");
         }
         
         // CSS style includes
         for (final String css : PageTag.CSS)
         {
            out.write(STYLES_START);
            out.write(reqPath);
            out.write(css);
            out.write(STYLES_MAIN);
         }
         
         // JavaScript includes
         for (final String s : PageTag.SCRIPTS)
         {
            out.write(SCRIPTS_START);
            out.write(reqPath);
            out.write(s);
            out.write(SCRIPTS_END);
         }
         
         out.write("\n"); // end - generate naked javascript code

         if (!Application.inPortalServer())
         {
            out.write("");
            out.write("\n");
         }
      }
      catch (IOException ioe)
      {
         throw new JspException(ioe.toString());
      }
      
      return EVAL_BODY_INCLUDE;
   }

   /**
    * @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
    */
   public int doEndTag() throws JspException
   {
      try
      {
         HttpServletRequest req = (HttpServletRequest)pageContext.getRequest();
         if (req.getRequestURI().endsWith(getLoginPage()) == false)
         {
            pageContext.getOut().write(getAlfrescoButton());
         }
         
         if (!Application.inPortalServer())
         {
            pageContext.getOut().write("\n");
         }
      }
      catch (IOException ioe)
      {
         throw new JspException(ioe.toString());
      }
      
      if (logger.isDebugEnabled())
      {
         long endTime = System.currentTimeMillis();
         logger.debug("Time to generate page: " + (endTime - startTime) + "ms");
      }
      
      return super.doEndTag();
   }
   
   private String getLoginPage()
   {
      if (PageTag.loginPage == null)
      {
         PageTag.loginPage = Application.getLoginPage(pageContext.getServletContext());
      }
      
      return PageTag.loginPage;
   }

/**
 * Please ensure you understand the terms of the license before changing the contents of this file.
 */

   private String getAlfrescoButton()
   {
      if (PageTag.alfresco == null)
      {
         final HttpServletRequest req = (HttpServletRequest)pageContext.getRequest();
 
PageTag.alfresco = ("<center><table style='margin: 0px auto;'><tr><td>"  
                             "<a href='"   ALF_URL   "'>"  
                             "<img style='vertical-align:middle;border-width:0px;' alt='' title='"   ALF_TEXT   
                             "' src='"   reqPath   ALF_LOGO   "'/>"  
                             "</a></td><td align='center'>"  
                             "<span class='footer'>"   ALF_COPY  
                             "</span></td><td>"  
                             "</td></tr></table></center>");
      }
      return PageTag.alfresco;
   }

   /**
    * This method generate code for setting window.onload reference as
    * we need to open WebDav or CIFS URL in a new window.
    * 
    * Executes via javascript code(function onloadFunc()) in "onload.js" include file.
    * 
    * @return Returns window.onload javascript code
    */
   private static void generateWindowOnloadCode(Writer out)
      throws IOException
   {
      FacesContext fc = FacesContext.getCurrentInstance();
      if (fc != null)
      {
          CCProperties ccProps = (CCProperties)FacesHelper.getManagedBean(fc, "CCProperties");
          if (ccProps.getWebdavUrl() != null || ccProps.getCifsPath() != null)
          {
             out.write("window.onload=onloadFunc(\"");
             if (ccProps.getWebdavUrl() != null)
             {
                out.write(ccProps.getWebdavUrl());
             }
             out.write("\",\"");
             if (ccProps.getCifsPath() != null)
             {
                String val = ccProps.getCifsPath();
                val = Utils.replace(val, "\\", "\\\\");   // encode escape character
                out.write(val);
             }
             out.write("\");");
             
             // reset session bean state
             ccProps.setCifsPath(null);
             ccProps.setWebdavUrl(null);
          }
      }
   }
}
----------------------------------------------------------------------------------
here i want to change  the following code to change the footer of alfresco.
   
   private final static String ALF_URL   = "http://aboutalfresco.blogspot.com/";
   private final static String ALF_LOGO  = "/images/MySite/footer_logo.gif";
   private final static String ALF_TEXT  = "Chandu Enterprise";
   private final static String ALF_COPY  = "Certified and supported. Chandu Software Inc. © 2005-2009 All rights reserved.";

Step5: add these jar files in lib



Step6: change remaining files  as per our requirement., here i changed login.jsp, relogin.jsp, getting-started.jsp, titlebar.jsp, error.jsp, noaccess.jsp.

Step7: add the below code in module.properties.





module.id=MySite-AlfrescoNewUI
module.title=MySite UI Project
module.description=MySite Project to build an amp file
module.version=1.0

Step8: Then go to build.xml ., right click on it then click on run as ant build. you will get the amp file in dist.as shown below.



Step9:  paste this amp file in to alfresco amp folder and click on apply_amps., then restart the server you can find the changes what you made.










Wednesday, April 7, 2010

Access the full Alfresco repository from the Share user interface

Alfresco 3.2r introduces the ability to access the full alfresco repo from share user interface

Here few steps are there.

step1: go to to tomcat\shared\classes\alfresco\web-extension
step2: rename the share-config-custom.xml.sample to share-config-custom.xml
step3: change the xml file as shown below which is marked in red color.


   <config evaluator="string-compare" condition="RepositoryLibrary" replace="true">
      <!--
         Whether the link to the Repository Library appears in the header component or not.
      -->
      <visible>true</visible>

      <!--
         Root nodeRef for top-level folder.
      -->
      <root-node>alfresco://company/home</root-node>

      <!--
         Whether the folder Tree component should enumerate child folders or not.
         This is a relatively expensive operation, so should be set to "false" for Repositories with broad folder structures.
      -->
      <tree>
         <evaluate-child-folders>false</evaluate-child-folders>
      </tree>
   </config>

step4: restart the server, then go to share admin dashboard you will find the screen as follows then click on repository.


step5: in the left side of the screen you can find the alfresco repository files as shown below.