Author: truong.le
Date: 2010-01-12 03:54:10 -0500 (Tue, 12 Jan 2010)
New Revision: 1230
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
Log:
GTNPORTAL-433: NPE when delete current portal in special case
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-01-12
08:28:00 UTC (rev 1229)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-01-12
08:54:10 UTC (rev 1230)
@@ -55,11 +55,13 @@
import org.exoplatform.webui.core.UITabPane;
import org.exoplatform.webui.core.UIWizard;
import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.event.EventListener;
import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+
/** Created by The eXo Platform SAS Author : Pham Thanh Tung thanhtungty(a)gmail.com Jun
10, 2009 */
@ComponentConfigs({
@ComponentConfig(template =
"app:/groovy/portal/webui/portal/UIPortalComposer.gtmpl", events = {
@@ -162,20 +164,10 @@
String remoteUser = prContext.getRemoteUser();
String ownerUser = prContext.getPortalOwner();
- String portalOwner = null;
- if (editPortal.getOwnerType().equals(PortalConfig.PORTAL_TYPE))
- {
- portalOwner = editPortal.getOwner();
- }
- else
- {
- portalOwner = Util.getPortalRequestContext().getPortalOwner();
- }
-
PortalConfig portalConfig =
(PortalConfig)PortalDataMapper.buildModelObject(editPortal);
UserPortalConfigService configService =
getApplicationComponent(UserPortalConfigService.class);
- if (configService.getUserPortalConfig(portalOwner, remoteUser) != null)
+ if (isPortalExist(editPortal))
{
configService.update(portalConfig);
}
@@ -226,7 +218,26 @@
SkinService skinService = getApplicationComponent(SkinService.class);
skinService.invalidatePortalSkinCache(editPortal.getName(), editPortal.getSkin());
}
+
+ public boolean isPortalExist(UIPortal editPortal) throws Exception
+ {
+ String remoteUser = Util.getPortalRequestContext().getRemoteUser();
+ String portalOwner = null;
+ if (editPortal.getOwnerType().equals(PortalConfig.PORTAL_TYPE))
+ {
+ portalOwner = editPortal.getOwner();
+ }
+ else
+ {
+ portalOwner = Util.getPortalRequestContext().getPortalOwner();
+ }
+
+ UserPortalConfigService configService =
getApplicationComponent(UserPortalConfigService.class);
+
+ return configService.getUserPortalConfig(portalOwner, remoteUser) != null;
+ }
+
public void updateWorkspaceComponent() throws Exception
{
UIPortalApplication uiApp = Util.getUIPortalApplication();
@@ -406,11 +417,32 @@
{
uri = uiPortal.getSelectedNode() != null ?
uiPortal.getSelectedNode().getUri() : null;
}
- PageNodeEvent<UIPortal> pnevent = new
PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
- prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
- JavascriptManager jsManager = prContext.getJavascriptManager();
- jsManager.addJavascript("eXo.portal.portalMode=" +
UIPortalApplication.NORMAL_MODE + ";");
+
+ if(uiComposer.isPortalExist(editPortal))
+ {
+ PageNodeEvent<UIPortal> pnevent = new
PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
+ uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
+ JavascriptManager jsManager = prContext.getJavascriptManager();
+ jsManager.addJavascript("eXo.portal.portalMode=" +
UIPortalApplication.NORMAL_MODE + ";");
+ }
+ else
+ {
+ if(editPortal.getOwner().equals(prContext.getPortalOwner()))
+ {
+ HttpServletRequest request = prContext.getRequest();
+ request.getSession().invalidate();
+ prContext.setResponseComplete(true);
+ prContext.getResponse().sendRedirect(request.getContextPath());
+ return;
+ }
+ else
+ {
+ UIApplication uiApp = prContext.getUIApplication();
+ uiApp.addMessage(new
ApplicationMessage("UIPortalForm.msg.notExistAnymore", null));
+ prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
+ }
+ }
}
}
Show replies by date