Program: 101223
Project: 101223
Buggy source:
public void execute(Event<UIPageForm> event) throws Exception {
  UIPageForm uiPageForm=event.getSource();
  UIPortalApplication uiPortalApp=event.getSource().getAncestorOfType(UIPortalApplication.class);
  PortalRequestContext pcontext=Util.getPortalRequestContext();
  UIPage uiPage=uiPageForm.getUIPage();
  Page page=new Page();
  uiPageForm.invokeSetBindingBean(page);
  UserPortalConfigService configService=uiPageForm.getApplicationComponent(UserPortalConfigService.class);
  UIMaskWorkspace uiMaskWS=uiPortalApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
  uiMaskWS.setUIComponent(null);
  uiMaskWS.setShow(false);
  pcontext.addUIComponentToUpdateByAjax(uiMaskWS);
  if (uiPage == null) {
    DataStorage dataStorage=uiPageForm.getApplicationComponent(DataStorage.class);
    Page existPage=dataStorage.getPage(page.getPageId());
    if (existPage != null) {
      uiPortalApp.addMessage(new ApplicationMessage("String_Node_Str",null));
      pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
      return;
    }
    page.setCreator(pcontext.getRemoteUser());
    page.setModifiable(true);
    if (page.getChildren() == null)     page.setChildren(new ArrayList<Object>());
    configService.create(page);
    UIPortalToolPanel uiToolPanel=Util.getUIPortalToolPanel();
    UIPageBrowser uiBrowser=(UIPageBrowser)uiToolPanel.getUIComponent();
    uiBrowser.reset();
    pcontext.addUIComponentToUpdateByAjax(uiBrowser);
    return;
  }
  page.setOwnerType(uiPage.getOwnerType());
  List<UIPortlet> uiPortlets=new ArrayList<UIPortlet>();
  findAllPortlet(uiPortlets,uiPage);
  ArrayList<Object> applications=new ArrayList<Object>();
  for (  UIPortlet uiPortlet : uiPortlets) {
    applications.add(PortalDataMapper.toPortletModel(uiPortlet));
  }
  if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId()) && !Page.DESKTOP_PAGE.equals(page.getFactoryId())) {
    page.setShowMaxWindow(false);
    uiPage.getChildren().clear();
    page.setChildren(applications);
    page.setModifier(pcontext.getRemoteUser());
    PortalDataMapper.toUIPage(uiPage,page);
    if (page.getTemplate() == null)     page.setTemplate(uiPage.getTemplate());
    if (page.getChildren() == null)     page.setChildren(new ArrayList<Object>());
    configService.update(page);
    UIPortalToolPanel uiToolPanel=Util.getUIPortalToolPanel();
    UIPageBrowser uiBrowser=(UIPageBrowser)uiToolPanel.getUIComponent();
    uiBrowser.reset();
    pcontext.addUIComponentToUpdateByAjax(uiBrowser);
    return;
  }
  List<UIComponent> uiChildren=uiPage.getChildren();
  if (uiChildren == null)   return;
  ArrayList<Object> children=new ArrayList<Object>();
  for (  UIComponent child : uiChildren) {
    Object component=PortalDataMapper.buildChild(child);
    if (component != null)     children.add(component);
  }
  page.setChildren(children);
  uiPage.getChildren().clear();
  page.setModifier(pcontext.getRemoteUser());
  PortalDataMapper.toUIPage(uiPage,page);
  if (page.getTemplate() == null)   page.setTemplate(uiPage.getTemplate());
  if (page.getChildren() == null)   page.setChildren(new ArrayList<Object>());
  if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId())) {
    configService.update(page);
    UIPortalToolPanel uiToolPanel=Util.getUIPortalToolPanel();
    UIPageBrowser uiBrowser=(UIPageBrowser)uiToolPanel.getUIComponent();
    uiBrowser.reset();
    pcontext.addUIComponentToUpdateByAjax(uiBrowser);
  }
}

Fixed version (ground truth):
public void execute(Event<UIPageForm> event) throws Exception {
  UIPageForm uiPageForm=event.getSource();
  UIPortalApplication uiPortalApp=uiPageForm.getAncestorOfType(UIPortalApplication.class);
  PortalRequestContext pcontext=Util.getPortalRequestContext();
  UIPage uiPage=uiPageForm.getUIPage();
  Page page=new Page();
  uiPageForm.invokeSetBindingBean(page);
  UserPortalConfigService configService=uiPageForm.getApplicationComponent(UserPortalConfigService.class);
  if (uiPage == null) {
    DataStorage dataStorage=uiPageForm.getApplicationComponent(DataStorage.class);
    Page existPage=dataStorage.getPage(page.getPageId());
    if (existPage != null) {
      uiPortalApp.addMessage(new ApplicationMessage("String_Node_Str",null));
      pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getUIPopupMessages());
      return;
    }
    page.setCreator(pcontext.getRemoteUser());
    page.setModifiable(true);
    if (page.getChildren() == null)     page.setChildren(new ArrayList<Object>());
    configService.create(page);
    postSave(uiPortalApp,pcontext);
    return;
  }
  page.setOwnerType(uiPage.getOwnerType());
  List<UIPortlet> uiPortlets=new ArrayList<UIPortlet>();
  findAllPortlet(uiPortlets,uiPage);
  ArrayList<Object> applications=new ArrayList<Object>();
  for (  UIPortlet uiPortlet : uiPortlets) {
    applications.add(PortalDataMapper.toPortletModel(uiPortlet));
  }
  if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId()) && !Page.DESKTOP_PAGE.equals(page.getFactoryId())) {
    page.setShowMaxWindow(false);
    uiPage.getChildren().clear();
    page.setChildren(applications);
    page.setModifier(pcontext.getRemoteUser());
    PortalDataMapper.toUIPage(uiPage,page);
    if (page.getTemplate() == null)     page.setTemplate(uiPage.getTemplate());
    if (page.getChildren() == null)     page.setChildren(new ArrayList<Object>());
    configService.update(page);
    postSave(uiPortalApp,pcontext);
    return;
  }
  List<UIComponent> uiChildren=uiPage.getChildren();
  if (uiChildren == null)   return;
  ArrayList<Object> children=new ArrayList<Object>();
  for (  UIComponent child : uiChildren) {
    Object component=PortalDataMapper.buildChild(child);
    if (component != null)     children.add(component);
  }
  page.setChildren(children);
  uiPage.getChildren().clear();
  page.setModifier(pcontext.getRemoteUser());
  PortalDataMapper.toUIPage(uiPage,page);
  if (page.getTemplate() == null)   page.setTemplate(uiPage.getTemplate());
  if (page.getChildren() == null)   page.setChildren(new ArrayList<Object>());
  if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId())) {
    configService.update(page);
    postSave(uiPortalApp,pcontext);
  }
}