Configuration API
The Configuration API is part of the smarteditwebservices extension and provides a means of creating, retrieving, updating, and deleting (CRUD) attributes used by SmartEdit, such as attributes to initialize and load SmartEdit. The attributes are used in resources to represent the default tooling language, CMS JavaScript library paths, and white-listed URLs.
Facade
The Configuration API exposes the following facade to provide CRUD operations on key-value pair data:
public interface SmarteditConfigurationFacade
{
List<ConfigurationData> findAll();
ConfigurationData create(ConfigurationData configurationData);
ConfigurationData update(String uid, ConfigurationData configurationData);
ConfigurationData findByUid(String uid);
void delete(String uid);
}
Beans
The Configuration API relies on the following DTO as shown in this code excerpt from the beans.xml file.
<bean class="de.hybris.platform.smarteditwebservices.dto.ConfigurationDataListWsDto">
<property name="configurations" type="java.util.Collection<de.hybris.platform.smarteditwebservices.data.ConfigurationData>" />
</bean>
<bean class="de.hybris.platform.smarteditwebservices.data.ConfigurationData">
<property name="key" type="java.lang.String" />
<property name="value" type="java.lang.String" />
</bean>
<bean class="de.hybris.platform.smarteditwebservices.dto.UpdateConfigurationDto">
<property name="uid" type="java.lang.String" />
<property name="key" type="java.lang.String" />
<property name="value" type="java.lang.String" />
</bean>
Spring Configuration
The SmartEdit configuration facade exposes methods to get, create, update, and delete configuration data. The API declares the following Spring beans in the spring.xml file:
<!-- Facade --> <alias name="defaultSmartEditConfigurationFacade" alias="smarteditConfigurationFacade"/> <bean id="defaultSmartEditConfigurationFacade" class="de.hybris.platform.smarteditwebservices.configuration.facade.impl.DefaultSmarteditConfigurationFacade"> <property name="smarteditConfigurationService" ref="smarteditConfigurationService"/> <property name="configurationModelToDataConverter" ref="smarteditConfigurationModelToDataConverter"/> <property name="configurationDataToModelConverter" ref="smarteditConfigurationDataToModelConverter"/> <property name="createConfigurationValidator" ref="baseConfigurationValidator"/> <property name="updateConfigurationValidator" ref="updateConfigurationValidator"/> <property name="facadeValidationService" ref="smarteditDefaultFacadeValidationService"/> </bean
Converters and Populators
The smarteditConfigurationModelToDataConverter and smarteditConfigurationDataToModelConverter convert and populate the configuration DTO. The current configuration populates the key-value pair information.
<!-- Converters --> <bean id="smarteditConfigurationModelToDataConverter" parent="abstractPopulatingConverter"> <property name="targetClass" value="de.hybris.platform.smarteditwebservices.data.ConfigurationData" /> <property name="populators"> <list merge="true"> <ref bean="smarteditConfigurationModelToDataPopulator" /> </list> </property> </bean> <bean id="smarteditConfigurationDataToModelConverter" parent="abstractPopulatingConverter"> <property name="targetClass" value="de.hybris.platform.smarteditwebservices.model.SmarteditConfigurationModel" /> <property name="populators"> <list merge="true"> <ref bean="smarteditConfigurationDataToModelPopulator" /> </list> </property> </bean>
The following excerpt shows the Spring beans that are used to populate the configuration key-value pair:
<!-- Populators --> <bean id="smarteditConfigurationDataToModelPopulator" class="de.hybris.platform.smarteditwebservices.configuration.populator.SmarteditConfigurationDataToModelPopulator"/> <bean id="smarteditConfigurationModelToDataPopulator" class="de.hybris.platform.smarteditwebservices.configuration.populator.SmarteditConfigurationModelToDataPopulator"/>
Validators
The Configuration API utilizes the facade validation service to validate the inputted data before further processing. The service executes the baseConfigurationValidator and the updateConfigurationValidator during the verification step.
<!-- Validators --> <bean id="baseConfigurationValidator" class="de.hybris.platform.smarteditwebservices.configuration.validator.BaseConfigurationValidator"/> <bean id="updateConfigurationValidator" class="de.hybris.platform.smarteditwebservices.configuration.validator.UpdateConfigurationValidator"/>