Create a connection

Create a category for a connection

This file should be available from the relative path "WEB-INF\storage<custom><global>\education-global.xml".

<?xml version="1.0" encoding="UTF-8"?>
<definitions>
        <connector>
                <connection>
                        <categories>
                                <category name="education" label="connection.education.label" description="connection.education.description"/>
                        </categories>
                </connection>
        </connector>
</definitions>

Define a connection

This file should be available from the relative path "WEB-INF\storage<custom><connections>\education-mail.xml" within the final connectors package.

<?xml version="1.0" encoding="UTF-8"?>
<connections>   
        <connection-settings name="smtp.connection" category="education">
        </connection-settings>                          
</connections>

Associate a category and the runtime class to the connection

<?xml version="1.0" encoding="UTF-8"?>
<connections>   
        <connection-settings name="smtp.connection" category="education">
                <class qualifiedName="com.axemble.education.connectors.smtp.SampleSMTPConnection" />
        </connection-settings>                          
</connections>

Create the runtime class for the connection

Two methods have to be implemented:

  • getConnection(): should return either an object or a structure which contains all the useful information to connect to the external system;
  • validate(): tests the connection.
    package com.axemble.education.connectors.mail;
    
    import com.axemble.vdoc.sdk.connectors.BaseConnection;
    
    public class MailConnection extends BaseConnection
    {
            private static final long serialVersionUID = 8575257148794814192L;
    
            /* (non-Javadoc)
             * @see com.axemble.vdoc.sdk.connectors.BaseConnection#validate()
             */
            @Override
            public boolean validate() throws Exception
            {
                    return true;
            }
    
            /* (non-Javadoc)
             * @see com.axemble.vdoc.sdk.connectors.BaseConnection#getConnection()
             */
            @Override
            public Object getConnection()
            {
                    return null;
            }
    }

Set the configuration and the editor class of the connection

<?xml version="1.0" encoding="UTF-8"?>
<connections>   
        <connection-settings name="smtp.connection" category="education">
                <class qualifiedName="com.axemble.education.connectors.smtp.SampleSMTPConnection" />
                <configuration>
                        <class qualifiedName="com.axemble.education.connectors.smtp.SampleSMTPConnectionEditor" />
                        <section name="settings" label="LG_SETTINGS">
                                <fields>                                        
                                        <field name="fldMailBaseUrl" label="LG_MAIL_BASE_URL" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" />
                                        <field name="fldSmtpServer" label="LG_SMTP_SERVER" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="true" />
                                        <field name="fldSmtpPort" label="LG_SMTP_PORT" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" mandatory="true" />
                                        <field name="fldMailAdministrator" label="LG_SMTP_MAIL_ADMINISTRATOR" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" />
                                        <field name="fldMailSender" label="LG_SMTP_MAIL_SENDER" ctrl="com.axemble.vdp.ui.core.document.fields.TextBoxField" />
                                </fields>
                        </section>
                </configuration>
        </connection-settings>                          
</connections>

Create the editor class for the connection

package com.axemble.education.connectors.mail;

import com.axemble.vdoc.sdk.connectors.BaseConnectionEditor;

public class MailConnectionEditor extends BaseConnectionEditor
{
        private static final long serialVersionUID = -8506977980390428675L;
}