cancel
Showing results for 
Search instead for 
Did you mean: 

How can i customize api controllers from ycommercewebservice extension in 2211

rohit31_raj92
Active Participant
0 Kudos

Hi Everyone,

I'm trying to customize web services API controllers so exploring how we can do it in custom code base

1. I've created custom extension for my project via modulegen

2. I created commercewebservices extension via ant extgen, adding it to localextension

After i start my server, server breaks , duplicate bean errors is faced due to duplicate webservice extension, 1 created by me as custom and another OOTB ycommercewebservice, although my localextension.xml do not have entry for OOTB extension

so i am looking to know can't we create extension for commercewebservice and use it ? I was able to do it in past few versions. and if we can't then how we can customize the existing api controllers like CartsController etc.

If I use yoccadon or ywebservices as template then I get extension but it do not have controllers provided by Hybris OOTB so i need a way so i can have ootb api controllers as part of custom code base

Accepted Solutions (0)

Answers (1)

Answers (1)

StefanKruk
Active Participant
0 Kudos

With 2211 the OCC Concept was changed from Addons to Extensions.

To Override a specific Endpoint you can use the Annotation @de.hybris.platform.commerceservices.request.mapping.annotation.RequestMappingOverride

on a Custom Endpoint (with the same Mapping) to replace the Orginal one.

If multiple Extensions with the same Mappings exists you will be able to define the priority via Property. The method with the Highest Priority will be used.

rohit31_raj92
Active Participant
0 Kudos

Thank you @Stefan Kruk for response.

With 2211, does it mean that we will not be able to customize the code of api controllers if we need to ?

If am setting up new project code base then i couldn't have custom extension like we use to have using template ycommercerwebservices and we were able modify the api controllers logic or validator ? then how we can customize those ?

Like below ?

StefanKruk
Active Participant
0 Kudos

With 2211 the old OCC Addons are declared as deprecated and were replaced with dedicated Extensions.

Most Validators are wired by Bean name/id.
To Replace Validators you can set up an own occ Extension by using the `yocc` Template. In your new OCC Extension you will find the Structure <customocc>/resources/occ/v2/<customocc>/web/spring/<customocc>-web-spring.xml

This File will automatically be loaded by commercewebservices/WEB-INF/config/v2-web-spring.xml.

You can either use Default Validators (RegexValidator, FieldNotEmptyOrTooLongValidator, etc.) or implement your own Validator in <customocc>/src/package/for/validators/CustomValidator.java and define it as bean in your <customocc>-web-spring.xml