[ 
http://jira.nuxeo.org/browse/NXP-3295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=50887#action_50887
 ] 

Nel Taurisson commented on NXP-3295:
------------------------------------

In the org.nuxeo.ecm.platform.types.TypeService service, the public static Type 
mergeTypes(Type oldType, Type newType) method doesn't acrtually merge the 
layouts but overwrite them.

So, all the layouts for a specific type must be declared in the same contrib 
(the last that declares some layouts).

I'd propose to change the code of the mergeTypes method by replacing the 
layouts handling part with :

        Map<String, Layouts> layouts = newType.getLayouts();
        if (layouts != null && !layouts.isEmpty()) {
            Map<String, Layouts> oldLayoutsMergeCopy = new HashMap<String, 
Layouts>(oldType.getLayouts());
            oldLayoutsMergeCopy.putAll(layouts) ;
            oldType.setLayouts(oldLayoutsMergeCopy);
        }

This actually doesn't really merges the layouts "by mode" but merges the 
layouts modes. If you have, for the same type :
- In first contrib :
            <layouts mode="foo">
                <layout>bar</layout>
            </layouts>

- In second contrib :
            <layouts mode="foo">
                <layout>baz</layout>
            </layouts>
            <layouts mode="foofoo">
                <layout>foobar</layout>
            </layouts>

Then in the end you will have only baz layout in foo mode and foobar layout in 
foofoo mode.

Not merging the layouts for a mode enables one to reset the layouts for a given 
mode. Lets say that for a given type, I wan't to get rid of the default 
settings I could have a contrib with :
            <layouts mode="any">
            </layouts>

> Type service layouts merging
> ----------------------------
>
>                 Key: NXP-3295
>                 URL: http://jira.nuxeo.org/browse/NXP-3295
>             Project: Nuxeo Enterprise Platform
>          Issue Type: Bug
>            Reporter: Nel Taurisson
>            Assignee: Thierry Delprat
>         Attachments: TypeService.java.diff
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.nuxeo.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets

Reply via email to