cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot create Custom strategy for cockpit NG

raghavendra_desu
Contributor
0 Kudos

Hello experts,

I have tried creating custom strategy for one of my requirement in cockpit NG, but the strategy is not getting registered with the existing strategies. I have created and added to widget strategy using https://wiki.hybris.com/display/release5/Cockpit+Data+Integration+Layer+of+the+Next+Generation+Cockp... Can any one please help me on it.

Thanks in Advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi, registering original strategies in DataAcessStrategyExtender occurs in addAll() method, which is annotated with @PostConstruct, so you need to configure your spring bean DataAccessStrategyExtender to execute this method. It could be done in 2 ways:

  1. Enable annotation-based configuration by <context:annotation-config/>
  2. explicitly define init-method and destroy-method for that bean:

    <bean class="...DataAccessStrategyExtender" lazy-init="false" init-method="addAll" destroy-method="removeAll"> ... </bean>
We will definitely update documentation to add that information.
raghavendra_desu
Contributor
0 Kudos

I just want to check item level read permissions, so i have created a method and i want to call that method in canReadInstance(Object item) method of DefaultPlatformPermissionFacadeStrategy. So I have created DefaultCustomPlatformPermissionFacadeStrategy, which is extending DefaultPlatformPermissionFacadeStrategy. I have added this custom strategy in myExtension-backoffice-spring.xml as mentioned below.

  <bean class="com.hybris.cockpitng.dataaccess.util.DataAccessStrategyExtender" lazy-init="false" >
     <property name="permissionFacadeStrategies">
         <list>
             <bean class="com.hybris.backoffice.cockpitng.dataaccess.facades.permissions.DefaultCustomPlatformPermissionFacadeStrategy" parent="defaultPlatformPermissionFacadeStrategy"/>
         </list>
     </property>
     <property name="permissionFacadeStrategyRegistry" ref="permissionFacadeStrategyRegistry"/>
 </bean>

I have started my system in debug mode, and tested for method call. My strategy is not getting called at all. One more verification i have gone through is my back office application context is added to default backoffice application context.

So i don't have any clue, why my strategy is not getting added to the strategies.

former_member632755
Active Contributor
0 Kudos

Hi,

could you paste your spring configuration (and the file name in which you placed it) along with the implementation of com.hybris.cockpitng.dataaccess.facades.type.TypeFacadeStrategy#canHandle. In addition to that could you explain your business case? The mechanism you are asking for is rather low-level and I'm wondering if there is something better suited for your case in NG.

Regards, Wojtek

Former Member
0 Kudos

hi Did you see the next answer -> has the info you asked. Any help appreciated, 2 projects affected.

former_member632755
Active Contributor
0 Kudos

hi, my team will help asap.