You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Martin Becker (JIRA)" <ji...@apache.org> on 2018/01/15 14:31:02 UTC

[jira] [Commented] (OFBIZ-9403) DataResourceWorker: New method getMimeTypeFromFileName(...) with extracted (refactored) code from getMimeType(...) method

    [ https://issues.apache.org/jira/browse/OFBIZ-9403?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16326282#comment-16326282 ] 

Martin Becker commented on OFBIZ-9403:
--------------------------------------

Hi Deepak,

yes, you are right, (now) I would name it getMimeType, too.

I had chosen getMimeTypeFromFileName inspired by getMimeTypeFromImageFileName in the same class, I think.

 

The returning of the default mime-type octet-stream is because I did not want to change the behavior of the getMimeType method like it was before my refactoring, which actually returns this default if there is no mimeTypeId defined at the DataResource and therefore the method looks for a mimeType determined from filename (so it assumes it is a file and returns octet-stream if there is no special mimeType by file extension).

Maybe we should add a default parameter to the method signatures to optionally give in a default mime type if the caller needs one.

> DataResourceWorker: New method getMimeTypeFromFileName(...) with extracted (refactored) code from getMimeType(...) method
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-9403
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-9403
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: content
>    Affects Versions: Trunk
>            Reporter: Martin Becker
>            Assignee: Deepak Dixit
>            Priority: Trivial
>         Attachments: OFBIZ-9403_DataResourceWorker-getMimeType.patch
>
>
> The method DataResourceWorker.getMimeType(GenericValue) has been refactored into two separate methods. The new additional method getMimeTypeFromFileName(Delegator,Filename) solely focuses on getting the MimeType from the file extension and is invoked by getMimeType(GenericValue) if needed. getMimeType returns the type if possible via the data resource. This results in cleaner code with the responsibility of both methods clearly defined by the methods names.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)