cancel
Showing results for 
Search instead for 
Did you mean: 

Getting build error when using XSSFilterUtil from acceleratorstorefrontcommons in custom addon.

hemant_sharma_3
Discoverer

Hi,

I need to use XSSFilterUtil from acceleratorstorefrontcommons in CustomController.java which is present in my customoccaddon. The customoccaddon is installed on commercewebservices extension. When I am triggering build getting following errors :

1. ERROR in D:\******\core-customize\hybris\bin\modules\commerce-services\commercewebservices\web\addonsrc\customoccaddon\com\*****\controllers\CustomController.java (at line 5)

import de.hybris.platform.acceleratorstorefrontcommons.util.XSSFilterUtil;

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The import de.hybris.platform.acceleratorstorefrontcommons.util cannot be resolved

----------

2. ERROR in D:\******\core-customize\hybris\bin\modules\commerce-services\commercewebservices\web\addonsrc\customoccaddon\com\*****\controllers\CustomController.java (at line 255)

XSSFilterUtil.filter(commentData.getText());

^^^^^^^^^^^^^

XSSFilterUtil cannot be resolved

----------

2 problems (2 errors)

Following Solutions I have tried till now and getting same error :

1- Adding acceleratorstorefrontcommons as required extension in extensionsinfo.xml in my customoccaddon.

2- Adding acceleratorstorefrontcommons to buildPath of customoccaddon [Just for resolving eclipse import issue].

3- Installing acceleratorstorefrontcommons addon on commercewebservices extension.

Creating custom XSSFilterUtil will work, but i want to use OOTB one. Please assist.

Accepted Solutions (0)

Answers (1)

Answers (1)

adiputera
Active Participant

acceleratorstorefrontcommons is not an addon, so installing it will not work.

Adding it to requires extension of commercewebservices will not work either, because the class is located inside commonweb/src instead of web/src

Here's how to make OCC Controller/Add-on controller be able to access XSSFilterUtil (and other class in acceleratorstorefrontcommons/commonweb/src/)

  1. Add acceseleratorstorefrontcommons to required extension of OCC extension
  2. Edit buildcallbacks.xml of OCC extension, add this code:
<macrodef name="extensioncommercewebservices_before_build">
           
    <sequential>
                  
        <echo message="extensioncommercewebservices_before_build"/>
                  
        <foreachext>
                         
            <do>
                                
                <if>
                                       
                    <available file="${ext.@{extname}.path}/commonweb"/>
                                       
                    <then>
                                              
                        <echo message="Found commonweb extension:  @{extname}"/>
                                              
                        <copyCommonWebToExtension commonwebextension="@{extname}" commonwebresource="/src" target="extensioncommercewebservices"/>
                                           
                    </then>
                                    
                </if>
                             
            </do>
                      
        </foreachext>
               
    </sequential>
        
</macrodef>

Now controller of OCC extension can access class from acceleratorstorefrontcommons