AnsweredAssumed Answered

Get exception on action java class and open a popup dialog on share with details of the error

Question asked by 4535992 on Oct 11, 2017
Latest reply on Oct 12, 2017 by afaust

HI i built my extensions module with is action link anf form , now i want if anything happened during the execution of the action on the java code print a popup with info of the exception on share is possibile with spring surf extensions?

Here my extensions module code:

 

<extension>
    <modules>
        <module>
            <id>SignSurfAction</id>
            <version>${project.version}</version>
            <auto-deploy>true</auto-deploy>
            <configurations>               
                <config evaluator="string-compare" condition="DocumentLibrary">                 
                    <indicators>                      
                        <indicator id="it.abd.indicator.isSigned"
                            icon="signed-doc-16.png"
                            index="100"
                            label="it.abd.indicator.isSigned.label">
                            <evaluator>it.abd.alfresco.evaluator.isSignable</evaluator>
                        </indicator>
                    </indicators>
                    <toolbar-actions>
                          <action type="action-link" id="onSignSurfAction" label="menu.selected-items.signSurfAction" />
                      </toolbar-actions>
                </config>
                <config evaluator="string-compare" condition="DocLibActions">
                    <actions>
                        <action id="onSignSurfAction" icon="sign" type="javascript"
                            label="it.abd.doclib.action.signSurfAction.label">
                            <param name="function">onActionFormDialog</param>
                            <param name="itemKind">action</param>
                            <param name="itemId">signSurfAction</param> <!-- Repository action id = Spring Bean id -->
                            <param name="mode">create</param>
                            <param name="destination">{node.nodeRef}</param>
                            <param name="successMessage">it.abd.sign.doclib.action.signed.msg.success</param>
                            <param name="failureMessage">it.abd.sign.doclib.action.signed.msg.failure</param>

                 //if the action failed show the popup with the failed message, butn i want to customize the text based on

                //the java exception i get from the code java action class
                            <evaluator>it.abd.alfresco.evaluator.isSignable</evaluator>
                        </action>
                    </actions>
                    <actionGroups>
                        <actionGroup id="document-browse">                       
                                <action index="400" id="onSignSurfAction" />
                        </actionGroup>
                        <actionGroup id="document-details">
                                <action index="400" id="onSignSurfAction" />>
                        </actionGroup>
                    </actionGroups>
                </config>                
                <config evaluator="string-compare" condition="DocLibCustom">
                    <dependencies>    
                        <css src="/webdesktop-share-amp/css/toolbar/custom-toolbar.css"/>
                        <js src="/webdesktop-share-amp/js/corslite.js"/>                  
                    </dependencies>
                </config>
                <!-- ========================================================= -->
                <!-- FORMS  -->
                <!-- ========================================================= -->
                <config evaluator="string-compare" condition="signSurfAction"> <!-- ID for the Repository Action that this form is associated with -->
                    <forms>                  
                        <form>        
                            <edit-form template="/2-column-edit-form.ftl" />
                            <field-visibility>
                                <show id="firmaProfilo"/>                           
                                <show id="firmaOtp"/>
                                <show id="firmaLuogo"/>
                                <show id="firmaMotivo"/>   
                                <show id="firmaFirmatario"/>                 
                                <show id="firmaUsername"/>
                                <show id="firmaPassword"/>
                            </field-visibility>
                            <appearance>
                            
                                <field id="firmaProfilo" label-id="property.form.sign.firma.profilo">
                                    <control template="/org/alfresco/components/form/controls/profiloFirmaSelectOneDinamic.ftl"/>     
                                  </field>
                                  <field id="firmaOtp" label-id="property.form.sign.firma.otp">
                                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                                  </field>    
                                  <field id="firmaLuogo" label-id="property.form.sign.firma.luogo">
                                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                                  </field>                                                        
                                  <field id="firmaMotivo" label-id="property.form.sign.firma.motivo">
                                    <control template="/org/alfresco/components/form/controls/textarea.ftl" />
                                  </field>
                                  <field id="firmaFirmatario" label-id="property.form.sign.firma.firmatario">
                                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                                  </field>                            
                                 <field id="firmaUsername" label-id="property.form.sign.firma.username">
                                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                                 </field>
                                  <field id="firmaPassword" label-id="property.form.sign.firma.password">
                                    <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                                  </field>                            
                            </appearance>
                        </form>      
                    </forms>
                </config>                  
            </configurations>
        </module>
    </modules>
</extension>

 

And here my java action class:

public class SignSurfAction extends ActionExecuterAbstractBase  {
    @Override
    protected void executeImpl(Action action, NodeRef actionedUponNodeRef)  {
        try {
            //MY CODE
        } catch (Throwable t) {
            logger.debug("Servizio di firma non disponibile, impossibile proseguire l'azione",t);            
            throw new WebScriptException("Bla bla bla : " + t.getMessage(), t);
            //THERE IS A WAY TO PRINT THE MESSAGE OF THE EXECPTION ON A POPUP ON SHARE ?
        }
    }

 

    @Override
    protected void addParameterDefinitions(List<ParameterDefinition> paramList) {        
        paramList.add(new ParameterDefinitionImpl("firmaProfilo", DataTypeDefinition.TEXT, true, getParamDisplayLabel("firmaProfilo")));
        paramList.add(new ParameterDefinitionImpl("firmaTipoProfilo", DataTypeDefinition.TEXT, false, getParamDisplayLabel("firmaTipoProfilo")));
        paramList.add(new ParameterDefinitionImpl("firmaTipo", DataTypeDefinition.TEXT, false, getParamDisplayLabel("firmaTipo")));
        
        paramList.add(new ParameterDefinitionImpl("firmaUsername", DataTypeDefinition.TEXT, false, getParamDisplayLabel("firmaUsername")));
        paramList.add(new ParameterDefinitionImpl("firmaPassword", DataTypeDefinition.TEXT, false, getParamDisplayLabel("firmaPassword")));        
        paramList.add(new ParameterDefinitionImpl("firmaOtp", DataTypeDefinition.TEXT, false, getParamDisplayLabel("firmaOtp")));
        
        paramList.add(new ParameterDefinitionImpl("firmaLuogo", DataTypeDefinition.TEXT, false, getParamDisplayLabel("firmaLuogo")));
        paramList.add(new ParameterDefinitionImpl("firmaMotivo", DataTypeDefinition.TEXT, false, getParamDisplayLabel("firmaMotivo")));
        paramList.add(new ParameterDefinitionImpl("firmaFirmatario", DataTypeDefinition.TEXT, false, getParamDisplayLabel("firmaFirmatario")));
    }
}

 

There is a way to print the exception message of java on the text of the failure message on the extensions module of share?

Greetings.

Outcomes