Migration Notes 5.2 to 5.3
These migration notes assumes that you are going from a Heat Clinic 5.2 demo to the 5.3 demo. There might be additional migration steps necessary for your particular implementation of Broadleaf. If so, please let us know through our Gitter, our Google Group, or by submitting a pull request to this documentation repo at https://github.com/BroadleafCommerce/docs.
Overview of new features in the 5.3.0-GA release are detailed within [[5.3.0-GA Release Notes | 5.3.0 GA]].
This document also assumes that you are on the latest 5.2 GA patch version of Broadleaf (at time of writing, 5.2.2-GA). If you have not upgraded your site to be on the latest 5.2 patch version, please do so before continuing and see the optional migration docs for each 5.2 patch version.
Module Compatibility with 5.3
If you are using any other Broadleaf modules, then those module versions will need to be updated to be compatible with broadleaf framework 5.3. Here is a compatibility chart listing all of the module versions that are compatible with broadleaf 5.3.
Module Name | Version | Migration Notes |
---|---|---|
broadleaf-menu | 2.2.0-GA | |
broadleaf-multitenant-singleschema | 3.2.0-GA | |
broadleaf-theme | 2.3.0-GA | |
broadleaf-pricelist | 3.2.0-GA | |
broadleaf-custom-field | 2.2.0-GA | |
broadleaf-advanced-cms | 2.3.0-GA | Migration Notes |
broadleaf-advanced-offer | 2.3.0-GA | Migration Notes |
broadleaf-account-credit | 3.3.0-GA | Migration Notes |
broadleaf-advanced-inventory | 2.2.0-GA | |
broadleaf-common-modules-enterprise | 3.2.0-GA | |
broadleaf-jobs-events | 2.2.0-GA | |
broadleaf-i18n-enterprise | 2.2.0-GA | |
broadleaf-enterprise | 3.3.0-GA | Migration Notes |
broadleaf-account | 2.4.0-GA | Migration Notes |
broadleaf-enterprise-search | 2.2.0-GA | |
broadleaf-customer-segment | 1.3.0-GA | |
broadleaf-merchandising-group | 1.2.0-GA | |
broadleaf-api | 2.2.0-GA | |
broadleaf-oms | 2.4.0-GA | Migration Notes |
broadleaf-cart-rules | 1.1.0-GA | |
broadleaf-common-presentation | 1.0.2-GA | |
broadleaf-thymeleaf-presentation | 1.1.0-GA | |
broadleaf-product-type | 1.1.0-GA | |
broadleaf-catalog-access-policy | 1.1.0-GA | |
broadleaf-punchout2go | 1.2.0-GA | |
broadleaf-quote | 1.3.0-GA | Migration Notes |
broadleaf-marketplace | 1.1.0-GA | Migration Notes |
broadleaf-process | 1.0.0-GA | |
broadleaf-export | 1.0.0-GA | |
broadleaf-import | 2.3.0-GA | |
broadleaf-affiliate | 1.0.0-GA | |
broadleaf-contenttests | 2.2.0-GA | |
broadleaf-free-geo-ip | 1.0.0-GA | |
broadleaf-max-mind-geo | 1.0.0-GA |
Schema Changes
There are a number of schema changes involved in the upgrade from 5.2.x to 5.3.0-GA. Be sure to check the migration notes for each sub-module. For core, the schema changes necessary can be found below. As always, we recommend using liquibase and Hibernate update to generate a changelog to be sure things are accurate for your environment.
<changeSet id="0" author="developer">
<addColumn tableName="BLC_OFFER_AUDIT">
<column name="ACCOUNT_ID" type="bigint"/>
</addColumn>
</changeSet>
<changeSet id="1" author="developer">
<createIndex tableName="BLC_OFFER_AUDIT" indexName="OFFERAUDIT_ACCOUNT_INDEX">
<column name="ACCOUNT_ID"/>
<column name="OFFER_ID"/>
</createIndex>
</changeSet>
<changeSet id="2" author="developer">
<dropIndex tableName="BLC_OFFER_AUDIT" indexName="OFFERAUDIT_CUSTOMER_INDEX"/>
</changeSet>
<changeSet id="3" author="developer">
<createIndex tableName="BLC_OFFER_AUDIT" indexName="OFFERAUDIT_CUSTOMER_INDEX">
<column name="CUSTOMER_ID"/>
<column name="OFFER_ID"/>
</createIndex>
</changeSet>
<changeSet id="4" author="developer">
<addColumn tableName="BLC_OFFER">
<column name="MAX_USES_STRATEGY" type="varchar(255)"/>
</addColumn>
</changeSet>
<changeSet id="5" author="developer">
<addColumn tableName="BLC_OFFER">
<column name="USE_LIST_FOR_DISCOUNTS" type="boolean"/>
</addColumn>
</changeSet>
<changeSet id="6" author="developer">
<sql>
CREATE TABLE BLC_OFFER_PRICE_DATA (
OFFER_PRICE_DATA_ID bigint PRIMARY KEY NOT NULL,
END_DATE timestamp,
START_DATE timestamp,
AMOUNT numeric NOT NULL,
ARCHIVED char(255),
CREATED_BY bigint,
DATE_CREATED timestamp,
DATE_UPDATED timestamp,
UPDATED_BY bigint,
DISCOUNT_TYPE varchar(255),
ADMIN_ADDITION_STATUS varchar(255),
CATALOG_DISC bigint,
SNDBX_CATALOG_FLAG bigint,
SNDBX_ORIG_ITEM_ID bigint,
SNDBX_ORIG_RECORD_ID bigint,
SNDBX_ID bigint,
SNDBX_ARCHIVED_FLAG char(255),
SNDBX_DELETED_FLAG char(255),
SNDBX_TMPLT_RECORD_ID bigint,
SNDBX_TIER bigint,
IDENTIFIER_TYPE varchar(255),
IDENTIFIER_VALUE varchar(255),
QUANTITY integer NOT NULL,
OFFER_ID bigint NOT NULL,
CONSTRAINT FKE0B2C929D5F3FAF4 FOREIGN KEY (OFFER_ID) REFERENCES BLC_OFFER (OFFER_ID)
);
CREATE INDEX IDX_BLOFPRDA_SNDBX_TEM_ID ON BLC_OFFER_PRICE_DATA (SNDBX_ORIG_ITEM_ID);
CREATE INDEX IDX_BLOFPRDA_SNDBX_ORD_ID ON BLC_OFFER_PRICE_DATA (SNDBX_ORIG_RECORD_ID);
CREATE INDEX IDX_BLOFPRDA_SNDBX_ID ON BLC_OFFER_PRICE_DATA (SNDBX_ID)
</sql>
</changeSet>
Note: This is a changelog for Liquibase, if you are not using Liquibase, you will need to translate this accordingly for your database platform.
Event Triggers
We added a number of new BroadleafApplicationEvent
triggers throughout the application. These event triggers are primarily listened to in order to send notifications, but your application could utilize them for other functionality.
Core
- Order Confirmation (OrderSubmittedEvent)
- Registration (RegisterCustomerEvent)
- Forgot Password (ForgotPasswordEvent)
- Forgot Username (ForgotUsernameEvent)
- Admin Forgot Password (AdminForgotPasswordEvent)
- Admin Forgot Username (AdminForgotUsernameEvent)
- Contact Us (ContactUsEvent)
GiftCardAndCustomerCredit
- Gift Card Submission (GiftCardEvent)
OMS
- Order Block (OrderBlockEvent)
- Order Change (OrderChangeEvent)
- Order Cancelled (OrderCancelledEvent)
- Fulfillment Order Fulfilled (FulfillmentOrderFulfilledEvent)
- Fulfillment Order Cancelled (FulfillmentOrderCancelledEvent)
- Return Authorization (ReturnAuthorizationEvent)
- Return Confirmation (ReturnConfirmationEvent)
Quote
- Quote Submitted (QuoteSubmittedEvent)
- Quote Accepted (QuoteAcceptedEvent)
- Quote Rejected (QuoteRejectedEvent)
Account
- Order Rejected (OrderRejectedEvent)
- Order Approved (OrderApprovedEvent)
- Order Pending Approval (OrderPendingApprovalEvent)
- Account Member Registration (RegisterAccountMemberEvent)
Enterprise
- Promotion Success (PromotionSuccessEvent)
- Promotion Failure (PromotionFailureEvent)
- Scheduled Deploy Success (ScheduledDeploySuccessEvent)
- Scheduled Deploy Failure (ScheduledDeployFailureEvent)
Marketplace
- Create Vendor Fulfillment Orders (CreateVendorFulfillmentOrdersEvent)
Async Events
BroadleafApplicationEvent's by default are published and handled synchronously. However, in many systems, the publishing and the handling of the events should likely happen asynchronously. This way if there is an issue in the code consuming the event, the original workflow does not fail. There are a few steps in order to ensure these events are handled asynchronously.
- Extend
AbstractBroadleafApplicationEventListener
and setisAsynchronous
to returntrue
. - Register a TaskExecutor bean with the name
blApplicationEventMulticastTaskExecutor
. This will result in that TaskExecutor being used to run the handler code asynchronously.
Another option to handle these events asynchronously is to utilize Broadleaf's ScheduledJobsAndEvents module. This is available for enterprise client's and instructions to utilize these jobs and events can be found in the module documentation.
Part of this release includes significant changes to the internal APIs for handling emails. This includes the addition of a new service, NotificationDispatcher
, which is now used instead of the deprecated EmailService
. These changes were made in order to better support other types of notifications, such as SMS. In addition, the enterprise module, AdvancedCMS, now includes Email and SMS templating domain to allow admin management of notification metadata and content.
We tried to make the API changes backwards compatible as much as possible. If you are upgrading from 5.2 to 5.3 of Broadleaf, you will need to make some minor changes to ensure your existing emails still work.
Minimal Migration (keep things the same)
- Set the
emailType
property on each of yourEmailInfo
beans to match theNotificationEventType
, e.g. your order confirmation info would have the email typeORDER_CONFIRMATION
. The primary
NotificationService
bean used to handle aEmailNotification
isblEmailNotificationService
. When AdvancedCMS is included, this is of typeEmailTemplateNotificationService
; when it is not included, this is of typeDefaultEmailNotificationService
. To stick with the same email functionality as before, be sure this bean is overridden to be of typeDefaultEmailNotificationService
.@Bean public NotificationService blEmailNotificationService() { return new DefaultEmailNotificationService(); }
Some of our internal email template names have changed. For instance, if the email template name was
promote-success.html
, it will now bepromote_success.html
. We advise those migrating to follow the same naming convention; lowercase and word-delimited by underscores.EmailService
is deprecated and we highly suggest any use of this service to be refactored to useNotificationDispatcher
. This change is relatively straightforward.// BEFORE public void sendEmail(String email, EmailInfo emailInfo, Map<String, Object> props) { emailService.sendTemplateEmail(email, emailInfo, props); } // AFTER public void sendEmail(String email, EmailInfo emailInfo, Map<String, Object> props) { NotificationEventType type = NotificationEventType.getInstance(emailInfo.getType()); try { notificationDispatcher.dispatchNotification(new EmailNotification(email, type, props)); } catch (ServiceException e) { // LOG or handle error, typically happens when email fails to send } }
Email Template Migration
Part of this change requires renaming email templates to fit a common pattern. All email templates need to be lowercase and underscore delimited, e.g. orderConfirmation-email.html
becomes order_confirmation_email.html
. This pattern is definitely required for any internal Broadleaf email infos you are utilizing, and conditionally required for your own. In addition, if you are using AdvancedCMS and the new EmailTemplate domain, you will need to follow this template naming pattern.
If you are using the enterprise version of Broadleaf and have AdvancedCMS in your project, you will have the opportunity to leverage the new email template functionality. For instructions on how to utilize this functionality, please refer to the AdvancedCMS module documentation.
Adding New Email Notification
Sometimes you may want to add a new Notification to your application that we haven't already included. This is relatively straightforward if you follow these steps:
Create a new
NotificationEventType
bean@Component public MyNotificationEventType extends NotificationEventType { public static final NotificationEventType MY_NOTIFICATION = new NotificationEventType("MY_NOTIFICATION", "My Notification"); }
Dispatch a new notification with that type
@Autowired @Qualifier("blNotificationDispatcher") protected NotificationDispatcher notificationDispatcher; public void sendMyNotification(Customer customer) { try { Map<String, Object> context = new HashMap<>(); context.put("customer", customer); notificationDispatcher.dispatchNotification( new EmailNotification( customer.getEmailAddress(), MyNotificationEventType.MY_NOTIFICATION, context ) ); } catch(ServiceException e) { // handle error, probably just log something } }
Add the EmailInfo for this notification (or EmailTemplate if using AdvancedCMS)
@Bean public EmailInfo myNotificationInfo() { EmailInfo emailInfo = new EmailInfo(); emailInfo.setFromAddress("me@mycompany.com"); emailInfo.setSubject("My Subject"); emailInfo.setEmailType(MyNotificationEventType.MY_NOTIFICATION.getType()); return emailInfo; }
Now the DefaultEmailNotificationService
within NotificationDispatcher
should pick up your EmailInfo
and send that email when sendMyNotification
is called.
Publishing Application Context Events
We have no added a new bean blApplicationEventPublisher
of the class org.broadleafcommerce.common.event.BroadleafApplicationEventPublisherImpl
for publishing application context events.
This should be used instead of the ApplicationContext
for publishing events. This new service ensures that any event published in the middle of the transaction is not actually dispatched until
after the transaction has been completed. This is useful since many times you want to publish an event during a transactional operation, but you don't want the event to be handled asynchronously
before the transaction has closed and any data changes have been committed.