protected void updateLayoutSetPrototype(Layout layout, Date modifiedDate) {
    if (layout == null) {
      return;
    }

    Group group = null;

    try {
      group = layout.getGroup();

      if (!group.isLayoutSetPrototype()) {
        return;
      }
    } catch (PortalException pe) {
      return;
    }

    try {
      LayoutSetPrototype layoutSetPrototype =
          LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype(group.getClassPK());

      layoutSetPrototype.setModifiedDate(modifiedDate);

      LayoutSetPrototypeLocalServiceUtil.updateLayoutSetPrototype(layoutSetPrototype);

      LayoutSet layoutSet = layoutSetPrototype.getLayoutSet();

      layoutSet.setModifiedDate(layout.getModifiedDate());

      UnicodeProperties settingsProperties = layoutSet.getSettingsProperties();

      settingsProperties.remove(Sites.MERGE_FAIL_COUNT);

      LayoutSetLocalServiceUtil.updateLayoutSet(layoutSet);
    } catch (Exception e) {
      _log.error(e, e);
    }
  }
 @Override
 public void onAfterUpdate(Layout layout) {
   updateLayoutSetPrototype(layout, layout.getModifiedDate());
 }