Page 1 of 1

Source code for the WS template copy fix

Posted: Fri Jan 30, 2009 7:00 pm
by mkalen
Could you please attach a patch or Java source code to the following issue: https://sourceforge.net/tracker2/?func= ... tid=848488 ?

I would like to integrate the fix with my customized WebService.

Thanks!

Posted: Mon Feb 02, 2009 12:49 pm
by maschoff
Done!

Thank you

Posted: Mon Feb 02, 2009 12:58 pm
by mkalen
Great! Thanks for your prompt response.
Cheers,
Martin

Re: Source code for the WS template copy fix

Posted: Mon Feb 02, 2009 2:06 pm
by mkalen
ma wrote:Done!
Thanks again for this. I have a few comments on the fixed version of the loadTemplate function:

1. Since the clone() method of the Mailing class is now used, every component will be loaded from the template. This includes the text- and HTML-components and the following code from EmmWebservice loadTemplate-function is now useless and can be removed:

Code: Select all

            // load template for this mailing
    		if((tmpComp = template.getHtmlTemplate()) != null) {
    			aMailing.addComponent(tmpComp);
    		}

    		if((tmpComp = template.getTextTemplate()) != null) {
    			aMailing.addComponent(tmpComp);
    		}
This is now basically dead code that will only result in "check if component key exists+bail out" of the Mailing#addComponent method. You can trace the code to verify this.

2. It seems that you might have forgotten to update the newEmailMailingWithReply method with regards to setting description, shortname and company id. The following lines are moved to after the loadTemplate call only in newEmailMailing and not newEmailMailingWithReply:

Code: Select all

        aMailing.setDescription(description);
        aMailing.setShortname(shortname);
        aMailing.setCompanyID(1);
I think they should always come after loadTemplate, since clone will otherwise overwrite description+shortname from template.

3. The overwrite check of agnText/agnHtml guarded by:

Code: Select all

if(aMailing.getMailTemplateID() == 0)
is in newEmailMailing but not in newEmailMailingWithReply. Ie. using newEmailMailingWithReply will still overwrite the contents of the template if the check is not added there as well (for both HTML and text components).

Posted: Thu Feb 19, 2009 3:37 pm
by maschoff
Thanks for your detailed feedback! Please see this bug fix at SourceForge:

https://sourceforge.net/tracker2/?func= ... _id=168937