enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
201 stars 34 forks source link

Handle case of '/content' node and call to controllers with content path '/' #6506

Closed GlennRicaud closed 6 years ago

GlennRicaud commented 6 years ago

The main question to answer is the following: Is the node '/content' a content or are contents only the nodes under '/content'? (I would now balance to '/content' not being a content)

There are many inconsistencies at different level:

At data level: Not treated as a content: The node '/content' has a _nodeType "default" and not "content", unlike other contents Treated as a content: The node '/content' has a type "base:folder", a displayName "Content", ... Basically all the properties of a content

Content Service: Treated as a content: Retrieving the content for the path '/' through the content service will return the node '/content'

ContentPath: Not treated as a content: You cannot really create a ContentPath for the content path '/'. There is event a check "No content can be "root content": " somewhere in the code.

Portal: Treated as a content: If you call a controller (example: http://localhost:8080/portal/draft/_/service/com.enonic.app.myapp/myservice) without a content path, the current content is the node '/content'. A call to portalLib.getContent will return the node '/content' as a content.

An obvious impact of this inconsistencies is for URL generation,

Example of test:

exports.get = function () {
    return {
        body: require('/lib/xp/portal').serviceUrl({
            'service': 'myservice'
        })
    };
};

Correct: http://localhost:8080/portal/draft/features/_/service/com.enonic.app.features/test /portal/draft/features/_/service/com.enonic.app.features/myservice http://localhost:8080/portal/draft/features/subcontent/_/service/com.enonic.app.features/test /portal/draft/features/subcontent/_/service/com.enonic.app.features/myservice

Incorrect(execute while being admin or cms.cm.app) http://localhost:8080/portal/draft/_/service/com.enonic.app.features/test /portal/draft/content/_/service/com.enonic.app.features/myservice

GlennRicaud commented 6 years ago

@runarmyklebust, @sigdestad : I would like confirmation that the node '/content' is not a content.

sigdestad commented 6 years ago

Confirmed!