gt:       UIActionLink link = (UIActionLink)event.getComponent();
context: /*
   * 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 <http://www.gnu.org/licenses/>. 
   */
  package org.alfresco.web.bean.coci;
  
  import java.io.Serializable;
  import java.text.MessageFormat;
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.faces.context.FacesContext;
  import javax.faces.event.AbortProcessingException;
  import javax.faces.event.ActionEvent;
  
  import org.alfresco.model.ApplicationModel;
  import org.alfresco.model.ContentModel;
  import org.alfresco.repo.content.MimetypeMap;
  import org.alfresco.repo.transaction.RetryingTransactionHelper;
  import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
  import org.alfresco.repo.version.VersionModel;
  import org.alfresco.repo.web.scripts.FileTypeImageUtils;
  import org.alfresco.service.cmr.repository.ContentData;
  import org.alfresco.service.cmr.repository.ContentReader;
  import org.alfresco.service.cmr.repository.ContentWriter;
  import org.alfresco.service.cmr.repository.InvalidNodeRefException;
  import org.alfresco.service.cmr.repository.NodeRef;
  import org.alfresco.service.cmr.version.Version;
  import org.alfresco.service.cmr.version.VersionType;
  import org.alfresco.web.app.AlfrescoNavigationHandler;
  import org.alfresco.web.app.Application;
  import org.alfresco.web.app.context.UIContextService;
  import org.alfresco.web.app.servlet.DownloadContentServlet;
  import org.alfresco.web.bean.BrowseBean;
  import org.alfresco.web.bean.FileUploadBean;
  import org.alfresco.web.bean.NavigationBean;
  import org.alfresco.web.bean.dialog.BaseDialogBean;
  import org.alfresco.web.bean.repository.Node;
  import org.alfresco.web.bean.repository.Repository;
  import org.alfresco.web.ui.common.ReportedException;
  import org.alfresco.web.ui.common.Utils;
  import org.alfresco.web.ui.common.component.UIActionLink;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * @author Kevin Roast
   */
  public class CheckinCheckoutDialog extends BaseDialogBean
  {
     // ------------------------------------------------------------------------------
     // Private data
  
     private static final long serialVersionUID = -4898900470274506760L;
  
     private static Log logger = LogFactory.getLog(CheckinCheckoutDialog.class);
  
     /* /** I18N messages */
     public static final String MSG_ERROR_CHECKIN = "error_checkin";
     public static final String MSG_ERROR_CANCELCHECKOUT = "error_cancel_checkout";
     public static final String MSG_ERROR_UPDATE = "error_update";
     public static final String MSG_ERROR_CHECKOUT = "error_checkout";
     private final static String MSG_LEFT_QUOTE = "left_qoute";
     private final static String MSG_RIGHT_QUOTE = "right_quote";
  
     public static final String FILE = "file";
     
     protected CCProperties property;
  
     // ------------------------------------------------------------------------------
     // Bean property getters and setters 
     
     /**
      * @param property the property to set
      */
     public void setProperty(CCProperties property)
     {
        this.property = property;
     }
     
     /**
      * @param navigator The NavigationBean to set.
      */
     public void setNavigator(NavigationBean navigator)
     {
        this.navigator = navigator;
     }
     
     /**
      * @return Returns the BrowseBean.
      */
     public BrowseBean getBrowseBean()
     {
        return this.browseBean;
     }
     
     /**
      * @param browseBean The BrowseBean to set.
      */
     public void setBrowseBean(BrowseBean browseBean)
     {
        this.browseBean = browseBean;
     }
     
     public boolean getFinishButtonDisabled()
     {
        return false;
     }
     
     public String getFinishButtonLabel()
     {
        return Application.getMessage(FacesContext.getCurrentInstance(), "check_in");
     }
     
     public String getContainerTitle()
     {
         FacesContext fc = FacesContext.getCurrentInstance();
         return Application.getMessage(fc, "check_in") + " " +
             Application.getMessage(fc, MSG_LEFT_QUOTE)+ this.property.getDocument().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
     }
     
     /**
      * Determines whether the document being checked in has 
      * the versionable aspect applied
      * 
      * @return true if the versionable aspect is applied
      */
     public boolean isVersionable()
     {
        return property.getDocument().hasAspect(ContentModel.ASPECT_VERSIONABLE);
     }
     
     /**
      * @return Returns the message to display when a file has been uploaded
      */
     public String getFileUploadSuccessMsg()
     {
        String msg = Application.getMessage(FacesContext.getCurrentInstance(), "file_upload_success");
        return MessageFormat.format(msg, new Object[] {Utils.encode(getFileName())});
     }
     
     /**
      * @return Returns the name of the file
      */
     public String getFileName()
     {
        // try and retrieve the file and filename from the file upload bean
        // representing the file we previously uploaded.
        FacesContext ctx = FacesContext.getCurrentInstance();
        FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
           get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
        if (fileBean != null)
        {
           property.setFile(fileBean.getFile());
           property.setFileName(fileBean.getFileName());
        }
        
        return property.getFileName();
     }
  
     /**
      * @param fileName The name of the file
      */
     public void setFileName(String fileName)
     {
        property.setFileName(fileName);
        
        // we also need to keep the file upload bean in sync
        FacesContext ctx = FacesContext.getCurrentInstance();
        FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
           get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
        if (fileBean != null)
        {
           fileBean.setFileName(property.getFileName());
        }
     }
  
     /**
      * Clear the uploaded form, clearing the specific Upload component by Id
      */
     protected void clearUpload(final String id)
     {
        // remove the file upload bean from the session
        final FacesContext ctx = FacesContext.getCurrentInstance();
        FileUploadBean fileBean = (FileUploadBean)
           ctx.getExternalContext().getSessionMap().get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
        if (fileBean != null)
        {
           fileBean.setFile(null);
           fileBean.setFileName(null);
        }
     }
     
     /**
      * Action handler called when the user wishes to remove an uploaded file
      */
     public String removeUploadedFile()
     {
        this.clearUpload(CheckinCheckoutDialog.FILE);
        property.setFileName(null) ;
        property.setFile(null);
        return null;
     }
     
     // ------------------------------------------------------------------------------
     // Navigation action event handlers
     
     /**
      * Action event called by all actions that need to setup a Content Document context on the 
      * CheckinCheckoutDialog before an action page/wizard is called. The context will be a Node in
      * setDocument() which can be retrieved on action pages via getDocument().
      * 
      * @param event   ActionEvent
      */
     public void setupContentAction(ActionEvent event)
     {
        UIActionLink link = (UIActionLink) event.getComponent();
        Map<String, String> params = link.getParameterMap();
        String id = params.get("id");
        if (id != null && id.length() != 0)
        {
           setupContentDocument(id);
        } 
        else
        {
           property.setDocument(null);
        }
        
        resetState();
     }
     
     public void setupWorkflowContentAction(ActionEvent event)
     {
        // do the common processing
        setupContentAction(event);
        
        // retrieve the id of the task
  