cancel
Showing results for 
Search instead for 
Did you mean: 

Create Action Problems

fbertos
Champ in-the-making
Champ in-the-making
Hi,

I've created a new Action, based in Transform Action. I've added two new
parameters (NodeRef):
   public static final String PARAM_CONTENT_HEADER = "contentHeader";

   protected void addParameterDefinitions(List<ParameterDefinition>
paramList)
   {
       paramList.add(new ParameterDefinitionImpl(PARAM_MIME_TYPE,
DataTypeDefinition.TEXT, true,
getParamDisplayLabel(PARAM_MIME_TYPE)));      
       paramList.add(new
ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER,
DataTypeDefinition.NODE_REF, true,
getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
       paramList.add(new
ParameterDefinitionImpl(PARAM_ASSOC_TYPE_QNAME,
DataTypeDefinition.QNAME, true,
getParamDisplayLabel(PARAM_ASSOC_TYPE_QNAME)));
       paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_QNAME,
DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASSOC_QNAME)));
       paramList.add(new ParameterDefinitionImpl(PARAM_OVERWRITE_COPY,
DataTypeDefinition.BOOLEAN, false,
getParamDisplayLabel(PARAM_OVERWRITE_COPY)));

    
       paramList.add(new ParameterDefinitionImpl(PARAM_CONTENT_HEADER,
DataTypeDefinition.NODE_REF, true,
getParamDisplayLabel(PARAM_CONTENT_HEADER)));
       paramList.add(new ParameterDefinitionImpl(PARAM_CONTENT_FOOTER,
DataTypeDefinition.NODE_REF, true,
getParamDisplayLabel(PARAM_CONTENT_FOOTER)));
   }

when I run the new action, I get the following error:
13:28:37,659 ERROR [ui.common.Utils] Failed to run Actions due to error:
[Ljava.lang.String;
java.lang.ClassCastException: [Ljava.lang.String;
   at
es.intecna.web.bean.actions.handlers.TransformHandler.prepareForSave(TransformHandler.java:50)
   at
org.alfresco.web.bean.actions.RunActionWizard.finishImpl(RunActionWizard.java:65)
   at
org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:89)
   at
org.alfresco.web.bean.wizard.WizardManager.finish(WizardManager.java:513)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at
org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
   at
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
   at javax.faces.component.UICommand.broadcast(UICommand.java:106)
   at
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
   at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
   at
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
   at
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:105)
   at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at
org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73)
   at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)

This is source code line which produces the error:
     protected static final String PROP_CONTENT_HEADER = "contentHeader";
     NodeRef headerNodeRef = (NodeRef)actionProps.get(PROP_CONTENT_HEADER);

My jsp action is using <r:contentSelector> for the new properties:

<r:contentSelector id="content-header-selector" multiSelect="false"
value="#{WizardManager.bean.actionProperties.contentHeader}"
styleClass="selector"/>

The Default Transform Action works fine. I have Alfresco Enterprise 1.4 & OO 2.0.3.

Can anybody help me, please?

Thanks in advance,

Regards,

fbertos
8 REPLIES 8

gavinc
Champ in-the-making
Champ in-the-making
The contentSelector component is returning a String array of the items selected in the component. The default TransformHandler is expecting a single NodeRef object to be returned, hence the ClassCastException.

So basically in your handler you'll need to get the String array and convert each item into a NodeRef manually.

fbertos
Champ in-the-making
Champ in-the-making
Thanks a lot.

Now, I'm getting the following exception: "Transaction has been rolled back because it has been marked as rollback-only", I've not modified the executeImpl method, I've used the source code from the org.alfresco.repo.action.executer.TransformActionExecuter class.

Thanks in advance.

fbertos.

gavinc
Champ in-the-making
Champ in-the-making
This could be caused by anything, you'll need to debug your code and get at the cause of the rollback exception.

Alternatively, you can add the following to your log4j.properties file to see the whole stack trace for the error, that may shed some light on what is going wrong.

log4j.logger.org.alfresco.web.ui.common.Utils=debug

fbertos
Champ in-the-making
Champ in-the-making
Hi,

This is my alfresco log, with the debug level in the logger.

14:51:42,537 ERROR [ui.common.Utils] Failed to run Actions due to error: Transaction has been rolled back because it has been marked as rollback-only
org.springframework.transaction.UnexpectedRollbackException: Transaction has been rolled back because it has been marked as rollback-only
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:465)
   at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:266)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
   at $Proxy19.executeAction(Unknown Source)
   at org.alfresco.web.bean.actions.RunActionWizard.finishImpl(RunActionWizard.java:74)
   at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:89)
   at org.alfresco.web.bean.wizard.WizardManager.finish(WizardManager.java:513)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
   at javax.faces.component.UICommand.broadcast(UICommand.java:106)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
   at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:105)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)

it seems to be an exception when commits the operations realised in the finishImpl method, but I don't know what's happening, the code is similar to the TransformAction class…

Thanks.

fbertos

gavinc
Champ in-the-making
Champ in-the-making
Unfortunately, that doesn't tell me much either as there is no cause logged. I think the best thing to do is to post your code in here so we can see what could possibly be causing the error.

fbertos
Champ in-the-making
Champ in-the-making
Ok, thanks a lot.

This is my Action Handler:

//———————————————————————————————
//———————————————————————————————
package es.intecna.web.bean.actions.handlers;

import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;

import javax.faces.context.FacesContext;

import org.alfresco.model.ContentModel;
import es.intecna.repo.action.executer.TransformActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;

import org.alfresco.web.bean.actions.handlers.BaseActionHandler;


/**
* Action handler for the "transform" action.
*
* @author gavinc
*/
public class TransformHandler extends BaseActionHandler
{
   protected static final String PROP_CONTENT_TEMPLATE = "contentTemplate";

   public String getJSPPath()
   {
      return "/jsp/extension/custom-transform.jsp";
   }

   public void prepareForSave(Map<String, Serializable> actionProps,
         Map<String, Serializable> repoProps)
   {
      // add the destination space id to the action properties
      NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
      repoProps.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
     
      // add the type and name of the association to create when the copy
      // is performed
      repoProps.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME,
            ContentModel.ASSOC_CONTAINS);
      repoProps.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
     
      String[] headerNodeRef = (String[])actionProps.get(PROP_CONTENT_TEMPLATE);
      repoProps.put(TransformActionExecuter.PARAM_CONTENT_TEMPLATE, headerNodeRef);
   }

   public void prepareForEdit(Map<String, Serializable> actionProps,
         Map<String, Serializable> repoProps)
   {
      NodeRef destNodeRef = (NodeRef)repoProps.get(TransformActionExecuter.PARAM_DESTINATION_FOLDER);
      actionProps.put(PROP_DESTINATION, destNodeRef);
     
      String[] headerNodeRef = (String[])repoProps.get(TransformActionExecuter.PARAM_CONTENT_TEMPLATE);
      actionProps.put(PROP_CONTENT_TEMPLATE, headerNodeRef);
   }

   public String generateSummary(FacesContext context, IWizardBean wizard,
         Map<String, Serializable> actionProps)
   {
      String label = null;
      NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
      String name = Repository.getNameForNode(Repository.getServiceRegistry(context).getNodeService(), space);
     
      return MessageFormat.format(Application.getMessage(context, "action_custom_transform"),
            new Object[] {name, label});
   }
}
//———————————————————————————————
//———————————————————————————————

This is my Action Executer:

package es.intecna.repo.action.executer;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.List;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.CopyService;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.NoTransformerException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.rule.RuleServiceException;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.alfresco.repo.content.MimetypeMap;

import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;

/**
* Transfor action executer
*
* @author Roy Wetherall
*/
public class TransformActionExecuter extends ActionExecuterAbstractBase
{
    /** Error messages */
    public static final String ERR_OVERWRITE = "Unable to overwrite copy because more than one have been found.";
   
    /**
     * The logger
     */
   private static Log logger = LogFactory.getLog(TransformActionExecuter.class);
   
    /**
     * Action constants
     */
   
   public static final String NAME = "custom-transform";
   public static final String PARAM_DESTINATION_FOLDER = "destination-folder";
    public static final String PARAM_OVERWRITE_COPY = "overwrite-copy";
    public static final String PARAM_ASSOC_TYPE_QNAME = "assoc-type";
    public static final String PARAM_ASSOC_QNAME = "assoc-name";
   public static final String PARAM_CONTENT_TEMPLATE = "content-template";

   private NodeService nodeService;
   private DictionaryService dictionaryService;
   private CopyService copyService;
   private ContentService contentService;
   
    /**
     * Set the mime type service
     *
     * @param mimetypeService  the mime type service
     */
   /*
    public void setMimetypeService(MimetypeService mimetypeService)
    {
        this.mimetypeService = mimetypeService;
    }
    */
   
    /**
     * Set the node service
     *
     * @param nodeService  set the node service
     */
    public void setNodeService(NodeService nodeService)
   {
      this.nodeService = nodeService;
   }

    /**
     * Set the dictionary service
     *
     * @param dictionaryService  the dictionary service
     */
   public void setDictionaryService(DictionaryService dictionaryService)
   {
      this.dictionaryService = dictionaryService;
   }
   
   /**
    * Set the content service
    *
    * @param contentService  the content service
    */
   public void setContentService(ContentService contentService)
   {
      this.contentService = contentService;
   }
   
   /**
    * Set the copy service
    *
    * @param copyService  the copy service
    */
   public void setCopyService(CopyService copyService)
   {
      this.copyService = copyService;
   }
   
   /**
    * Add parameter definitions
    */
   @Override
   protected void addParameterDefinitions(List<ParameterDefinition> paramList)
   {
        paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_TYPE_QNAME, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASSOC_TYPE_QNAME)));
        paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_QNAME, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASSOC_QNAME)));
      paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF, true, getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
        paramList.add(new ParameterDefinitionImpl(PARAM_OVERWRITE_COPY, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_OVERWRITE_COPY)));
      paramList.add(new ParameterDefinitionImpl(PARAM_CONTENT_TEMPLATE, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_CONTENT_TEMPLATE)));
   }

   /**
    * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
    */
   @Override
   protected void executeImpl(
         Action ruleAction,
         NodeRef actionedUponNodeRef)
   {
      if (this.nodeService.exists(actionedUponNodeRef) == false)
      {
            // node doesn't exist - can't do anything
            return;
        }
      
      // First check that the node is a sub-type of content
      QName typeQName = this.nodeService.getType(actionedUponNodeRef);

      if (this.dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT) == false)
      {
            // it is not content, so can't transform
            return;
        }
      
      // Get the mime type
      String mimeType = MimetypeMap.MIMETYPE_PDF;
         
      // Get the details of the copy destination
      NodeRef destinationParent = (NodeRef)ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER);
        QName destinationAssocTypeQName = (QName)ruleAction.getParameterValue(PARAM_ASSOC_TYPE_QNAME);
        QName destinationAssocQName = (QName)ruleAction.getParameterValue(PARAM_ASSOC_QNAME);
         
        NodeRef copyNodeRef = this.copyService.copy(
                actionedUponNodeRef,
                destinationParent,
                destinationAssocTypeQName,
                destinationAssocQName,
                false);

        // Adjust the name of the copy
        String originalName = (String)nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_NAME);
        String newName = transformName(originalName, mimeType);
        nodeService.setProperty(copyNodeRef, ContentModel.PROP_NAME, newName);
        String originalTitle = (String)nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_TITLE);
        String newTitle = "tmp.pdf";
       
        if (originalTitle != null && originalTitle.length() > 0)
        {
            newTitle = transformName(originalTitle, mimeType);
            nodeService.setProperty(copyNodeRef, ContentModel.PROP_TITLE, newTitle);
        }

        // Get the content reader
        ContentReader contentReader = this.contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
       
        // Only do the transformation if some content is available
        if (contentReader != null)
        {
            ContentWriter contentWriter = this.contentService.getWriter(copyNodeRef, ContentModel.PROP_CONTENT, true);
            contentWriter.setMimetype(mimeType);                        // new mimetype
            contentWriter.setEncoding(contentReader.getEncoding());     // original encoding

            try
            {
               doTransform(ruleAction, contentReader, contentWriter);
            }
            catch (NoTransformerException e)
            {
               if (logger.isDebugEnabled())
                {
                    logger.debug("No transformer found to execute rule: \n" +
                            "   reader: " + contentReader + "\n" +
                            "   writer: " + contentWriter + "\n" +
                            "   action: " + this);
                }            
            }
           
            /*
            contentReader = this.contentService.getReader(copyNodeRef, ContentModel.PROP_CONTENT);
           File file = new File("/tmp/" + newTitle);
           contentReader.getContent(file);
           
           //Aqui trasteamos el PDF
           
           try
           {
            FileInputStream inputStream = new FileInputStream(file);
               contentWriter = this.contentService.getWriter(copyNodeRef, ContentModel.PROP_CONTENT, true);
            contentWriter.putContent(inputStream);
            
            
         }
           catch (FileNotFoundException e)
           {
               if (logger.isDebugEnabled())
                {
                    logger.debug("No temp file found to execute rule: \n" +
                            "   reader: " + contentReader + "\n" +
                            "   writer: " + contentWriter + "\n" +
                            "   action: " + this);
                }                           
         }
         */
        }
   }   

   protected void doTransform(Action ruleAction, ContentReader contentReader, ContentWriter contentWriter)   
   {
      this.contentService.transform(contentReader, contentWriter);
   }
   
    /**
     * Transform name from original extension to new extension
     *
     * @param original
     * @param originalMimetype
     * @param newMimetype
     * @return
     */
    private String transformName(String original, String newMimetype)
    {
        // get the current extension
        int dotIndex = original.lastIndexOf('.');
        StringBuilder sb = new StringBuilder(original.length());
        if (dotIndex > -1)
        {
            // we found it
            sb.append(original.substring(0, dotIndex));
        }
        else
        {
            // no extension
            sb.append(original);
        }
        // add the new extension
        String newExtension = "pdf";
        sb.append('.').append(newExtension);
        // done
        return sb.toString();
    }
}

//———————————————————————————————
//———————————————————————————————

And this is my action handler jsp:

<%–
Copyright (C) 2005 Alfresco, Inc.

Licensed under the Mozilla Public License version 1.1
with a permitted attribution clause. You may obtain a
copy of the License at

http://www.alfresco.org/legal/license.txt

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific
language governing permissions and limitations under the
License.
–%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>

<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ page import="org.alfresco.web.ui.common.PanelGenerator" %>

<f:loadBundle basename="alfresco.messages.webclient" var="msg"/>

<rSmiley Tongueage titleId="msg.title_action_transform_custom">

<f:view>

<%– load a bundle of properties with I18N strings –%>

<h:form acceptCharset="UTF-8" id="transform-custom-action">

<%– Main outer table –%>
<table cellspacing="0" cellpadding="2">

<%– Title bar –%>
<tr>
<td colspan="2">
<%@ include file="../parts/titlebar.jsp" %>
</td>
</tr>

<%– Main area –%>
<tr valign="top">
<%– Shelf –%>
<td>
<%@ include file="../parts/shelf.jsp" %>
</td>

<%– Work Area –%>
<td width="100%">
<table cellspacing="0" cellpadding="0" width="100%">
<%– Breadcrumb –%>
<%@ include file="../parts/breadcrumb.jsp" %>

<%– Status and Actions –%>
<tr>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_4.gif)" width="4"></td>
<td bgcolor="#EEEEEE">

<%– Status and Actions inner contents table –%>
<%– Generally this consists of an icon, textual summary and actions for the current object –%>
<table cellspacing="4" cellpadding="0" width="100%">
<tr>
<td width="32">
<h:graphicImage id="wizard-logo" url="/images/icons/new_rule_large.gif" />
</td>
<td>
<div class="mainTitle"><hSmiley SurprisedutputText value="#{WizardManager.title}" /></div>
<div class="mainSubText"><hSmiley SurprisedutputText value="#{WizardManager.description}" /></div>
</td>
</tr>
</table>

</td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_6.gif)" width="4"></td>
</tr>

<%– separator row with gradient shadow –%>
<tr>
<td><img src="<%=request.getContextPath()%>/images/parts/statuspanel_7.gif" width="4" height="9"></td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_8.gif)"></td>
<td><img src="<%=request.getContextPath()%>/images/parts/statuspanel_9.gif" width="4" height="9"></td>
</tr>

<%– Details –%>
<tr valign=top>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_4.gif)" width="4"></td>
<td>
<table cellspacing="0" cellpadding="3" border="0" width="100%">
<tr>
<td width="100%" valign="top">

<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />

<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
<table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr>
<td colspan="2" class="mainSubTitle"><hSmiley SurprisedutputText value="#{msg.set_action_values}" /></td>
</tr>
<tr><td class="paddingRow"></td></tr>
<tr>
<td><hSmiley SurprisedutputText value="#{msg.destination}"/>:</td>
<td>
<r:spaceSelector id="space-selector" label="#{msg.select_destination_prompt}"
value="#{WizardManager.bean.actionProperties.destinationLocation}"
initialSelection="#{NavigationBean.currentNodeId}"
styleClass="selector"/>
</td>
</tr>
<tr>
<td><hSmiley SurprisedutputText value="Template"/>:</td>
<td>
<r:contentSelector id="content-template-selector" multiSelect="false"
value="#{WizardManager.bean.actionProperties.contentTemplate}"
styleClass="selector"/>
</td>
</tr>
<tr><td class="paddingRow"></td></tr>
</table>
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %>
</td>

<td valign="top">
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %>
<table cellpadding="1" cellspacing="1" border="0">
<tr>
<td align="center">
<h:commandButton value="#{msg.ok}" action="#{WizardManager.bean.addAction}" styleClass="wizardButton"
disabled="#{WizardManager.bean.actionProperties.destinationLocation == null}" />
</td>
</tr>
<tr>
<td align="center">
<h:commandButton value="#{msg.cancel_button}" action="#{WizardManager.bean.cancelAddAction}"
styleClass="wizardButton" />
</td>
</tr>
</table>
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %>
</td>
</tr>
</table>
</td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_6.gif)" width="4"></td>
</tr>

<%– separator row with bottom panel graphics –%>
<tr>
<td><img src="<%=request.getContextPath()%>/images/parts/whitepanel_7.gif" width="4" height="4"></td>
<td width="100%" align="center" style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_8.gif)"></td>
<td><img src="<%=request.getContextPath()%>/images/parts/whitepanel_9.gif" width="4" height="4"></td>
</tr>

</table>
</td>
</tr>
</table>

</h:form>

</f:view>

</rSmiley Tongueage>

//———————————————————————————————
//———————————————————————————————

This is the definition of the action:

    <bean id="custom-transform" class="es.intecna.repo.action.executer.TransformActionExecuter" parent="action-executer">
        <property name="nodeService">
            <ref bean="NodeService" />
        </property>
        <property name="dictionaryService">
            <ref bean="dictionaryService" />
        </property>
        <property name="copyService">
            <ref bean="CopyService" />
        </property>
        <property name="contentService">
            <ref bean="ContentService" />
        </property>
        <property name="applicableTypes">
           <list>
              <value>{http://www.alfresco.org/model/content/1.0}content</value>
           </list>
        </property>
    </bean>

In the web-client-custom-config-xml:

   <config evaluator="string-compare" condition="Action Wizards">
      <action-handlers>
         <handler name="custom-transform" class="es.intecna.web.bean.actions.handlers.TransformHandler" />
      </action-handlers>
   </config>

Thanks,

fbertos

gavinc
Champ in-the-making
Champ in-the-making
It may be something to do with the conversion of your parameter.

You have defined its type as DataTypeDefinition.ANY and you are passing a String array object.

As mentioned in a previous post you should really convert the Strings in the array to a NodeRef and change the parameter type to DataTypeDefinition.NODE_REF. If you have set the control on the JSP to only allow the selection of one content item (multiSelect="false") you can just get the first item from the array and create a NodeRef i.e. NodeRef ref = new NodeRef(arr[0]);

I think the best thing is for you to debug through your code and find the exact line that is throwing the exception.

fbertos
Champ in-the-making
Champ in-the-making
The finishImpl method doesn't throw any exception. The exception is thrown later (in RunActionWizard.finishImpl method).

I've been testing the code and the problem is calling to the transform method.

I've commented this line and works fine…

Thanks.