AnsweredAssumed Answered

Bug with Transform Services (simple patch included)

Question asked by kirby on Dec 18, 2005
Playing with the WebDAV access I discovered a bug in the Transform system.
I tried to upload a file from a Macintosh WebDAV client (Goliath), that set the mimetype as "text/plain; charset: utf-8".
That's a perfectly valid mimetype, but upload fails because Alfresco finds no translators for that mimetype in ContentTransformerRegistry: it's only defined for "text/plain".
I wrote a little patch for this bug, that try to cut the "optional" part of the mimetype if cannot find it in the list.
That's the code from ContentTransformer::getTransformer.

        // check that the mimetypes are valid
        // if there's no match, try simplifying it cutting the "options"
        if (!mimetypeMap.getMimetypes().contains(sourceMimetype))
        {
            String[] parsedMimetype = sourceMimetype.split(";");
            if (parsedMimetype.length > 0 && mimetypeMap.getMimetypes().contains(parsedMimetype[0]))
            {
                sourceMimetype = parsedMimetype[0];
            }
            else
            {
                throw new AlfrescoRuntimeException("Unknown source mimetype: " + sourceMimetype);
            }
        }
        if (!mimetypeMap.getMimetypes().contains(targetMimetype))
        {
            String[] parsedMimetype = targetMimetype.split(";");
            if (parsedMimetype.length > 0 && mimetypeMap.getMimetypes().contains(parsedMimetype[0]))
            {
                targetMimetype = parsedMimetype[0];
            }
            else
            {
                throw new AlfrescoRuntimeException("Unknown target mimetype: " + targetMimetype);
            }
        }

As a related question, where's the best place to submit patches for Alfresco? The Forum, the Jira or somewhere else?

Best regards,
Salvatore Insalaco

Outcomes