You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mime4j-dev@james.apache.org by "Stefano Bagnara (JIRA)" <mi...@james.apache.org> on 2011/04/17 12:34:05 UTC

[jira] [Created] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
----------------------------------------------------------------------------------

                 Key: MIME4J-192
                 URL: https://issues.apache.org/jira/browse/MIME4J-192
             Project: JAMES Mime4j
          Issue Type: Improvement
          Components: dom
    Affects Versions: 0.7
            Reporter: Stefano Bagnara
             Fix For: 0.7


Here is jDKIM use case:
----
    public Message(InputStream is) throws IOException, MimeException {
        MessageBuilder mb = newMessageBuilder();
        
        if (mb instanceof MessageBuilderImpl) {
        	((MessageBuilderImpl) mb).setFlatMode(true);
        	((MessageBuilderImpl) mb).setContentDecoding(false);
        }
        org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
        
        this.message = mImpl;
    }
----

Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Stefano Bagnara (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020784#comment-13020784 ] 

Stefano Bagnara commented on MIME4J-192:
----------------------------------------

Oleg: i'm sorry but I didn't want to touch the mime4j code as you already complained enough about my dom refactorings, so I just wanted to understand what was the right solution. Of course I could have added the 2 attributes myself if you simply replied "the current api doesn't have a solution, we can add this feature by adding an attribute in the implementation".

I don't agree with you about "flatmode" being an implementation detail. Flat mode tells the parser to adopt a different behaviour and return a different result. Is an interface detail (it alters the type of result you get from parse), not an implementation one. That said I'm fine anyway now that after r1094132 I can refactor jDKIM against trunk.

> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Oleg Kalnichevski (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020781#comment-13020781 ] 

Oleg Kalnichevski commented on MIME4J-192:
------------------------------------------

For the sake of sweet Jesus, Stefano, if you miss a particular configuration parameter in MessageServiceFactoryImpl, just go ahead and add it! What is the point of polluting an abstract interface with implementation specific details, when the whole problem can be better solved by changing a few lines in an impl class?

Please see http://svn.apache.org/viewvc?rev=1094132&view=rev

Oleg 

> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Oleg Kalnichevski (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020770#comment-13020770 ] 

Oleg Kalnichevski commented on MIME4J-192:
------------------------------------------

Am I missing something? 

---
    private MessageBuilder newMessageBuilder(boolean flatmode, boolean contentDecoding) throws MimeException {
---


> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Issue Comment Edited] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Oleg Kalnichevski (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020765#comment-13020765 ] 

Oleg Kalnichevski edited comment on MIME4J-192 at 4/17/11 10:47 AM:
--------------------------------------------------------------------

I am not in favor of adding setters to the MessageBuilder interface. 

Pass whatever parameters you need to your newMessageBuilder method and let it create an instance of MessageBuilder with the given parameters
----
    public Message(InputStream is) throws IOException, MimeException {
        MessageBuilder mb = newMessageBuilder(true, false);
        org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
        
        this.message = mImpl;
    }
---- 


      was (Author: olegk):
    I am not in favor of adding setters to MessageBuilder interface. 

Pass whatever parameters you need to your newMessageBuilder builder and let it create an instance of MessageBuilder with the given parameters
----
    public Message(InputStream is) throws IOException, MimeException {
        MessageBuilder mb = newMessageBuilder(true, false);
        org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
        
        this.message = mImpl;
    }
---- 

  
> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Oleg Kalnichevski (JIRA)" <mi...@james.apache.org>.
     [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved MIME4J-192.
--------------------------------------

    Resolution: Not A Problem

My _ONLY_ real complaint was about you not bringing your refactoring work to a logical conclusion of some sort.

Oleg

> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Stefano Bagnara (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020769#comment-13020769 ] 

Stefano Bagnara commented on MIME4J-192:
----------------------------------------

Hi Oleg, I can't understand your solution.

newMessageBuilder is a jdkim method and doesn't expose the 2 booleans:
---
    private MessageBuilder newMessageBuilder() throws MimeException {
        MimeEntityConfig mec = new MimeEntityConfig();
        mec.setMaxLineLen(10000);
        mec.setMaxHeaderLen(30000);
        
        MessageServiceFactory mbf = MessageServiceFactory.newInstance();
        mbf.setAttribute("MimeEntityConfig", mec);
        // mbf.setProperty("MaxLineLength", 10000);
        MessageBuilder mb = mbf.newMessageBuilder();
        return mb;
    }
---

I've checked the MessageServiceFactory and its newMessageBuilder method but it doesn't expose that parameters, too.
Can you give me an hint?

> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Oleg Kalnichevski (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020776#comment-13020776 ] 

Oleg Kalnichevski commented on MIME4J-192:
------------------------------------------

Stefano, please consider adding two parameters to the jdkim method you have been referring to, instead of adding respective setters to the MessageBuilder interface.

Oleg


> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Stefano Bagnara (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020773#comment-13020773 ] 

Stefano Bagnara commented on MIME4J-192:
----------------------------------------

I don't have a similar method
https://svn.apache.org/repos/asf/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/MessageServiceFactory.java

What class? 

> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Stefano Bagnara (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020780#comment-13020780 ] 

Stefano Bagnara commented on MIME4J-192:
----------------------------------------

Sorry but I still don't understand. Even if I add 2 booleans to jDKIM Message.newMessageBuilder I simply move the class cast from one method to another.

Ignoring jDKIM for a while and starting from mime4j MessageServiceFactory I can't find any path to set flatmode/contentdecoding without class casting. 

The question is: how can I use mime4j DOM API to do flat parsing without content decoding and without using class casting to mime4j internals? if I can't do this then the whole dom api is useless for jDKIM use case and I will simply move to new MessageBuilderImpl() as it doesn't make sense to use factories if I have to cast the result. I don't like this solution but I just want a confirmation that this is the right thing to do in your opinion.


> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Oleg Kalnichevski (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020765#comment-13020765 ] 

Oleg Kalnichevski commented on MIME4J-192:
------------------------------------------

I am not in favor of adding setters to MessageBuilder interface. 

Pass whatever parameters you need to your newMessageBuilder builder and let it create an instance of MessageBuilder with the given parameters
----
    public Message(InputStream is) throws IOException, MimeException {
        MessageBuilder mb = newMessageBuilder(true, false);
        org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
        
        this.message = mImpl;
    }
---- 


> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MIME4J-192) setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface

Posted by "Stefano Bagnara (JIRA)" <mi...@james.apache.org>.
    [ https://issues.apache.org/jira/browse/MIME4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020791#comment-13020791 ] 

Stefano Bagnara commented on MIME4J-192:
----------------------------------------

@Oleg, please accept that my "logical" is different from your "logical". That's why I need to ask questions now when I want to understand the current logic (as it is not logical for me). So, I'm fine with your logic, but given that I don't understand it please don't get upset when I ask questions on how I have to use it. 

If I put my hands in the code to fix stuff myself I will probably introduce something that is illogical for you (e.g. the logical solution to me was to add the methods to the interface) so I guess I did the right thing opening this bug and asking for your opinion and I can't accept your "for the sake of sweet Jesus" in reply.

> setFlatMode and setContentDecoding are not exposed by the MessageBuilder interface
> ----------------------------------------------------------------------------------
>
>                 Key: MIME4J-192
>                 URL: https://issues.apache.org/jira/browse/MIME4J-192
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>          Components: dom
>    Affects Versions: 0.7
>            Reporter: Stefano Bagnara
>             Fix For: 0.7
>
>
> Here is jDKIM use case:
> ----
>     public Message(InputStream is) throws IOException, MimeException {
>         MessageBuilder mb = newMessageBuilder();
>         
>         if (mb instanceof MessageBuilderImpl) {
>         	((MessageBuilderImpl) mb).setFlatMode(true);
>         	((MessageBuilderImpl) mb).setContentDecoding(false);
>         }
>         org.apache.james.mime4j.dom.Message mImpl = mb.parse(new EOLConvertingInputStream(is));
>         
>         this.message = mImpl;
>     }
> ----
> Is this the expected client pattern? Or should we expose setFlatMode and setContentDecoding in the MessageBuilder interface so to remove the class casting requirement?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira