Author: liem_nguyen
Date: 2009-12-28 21:12:57 -0500 (Mon, 28 Dec 2009)
New Revision: 1147
Modified:
portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
Log:
Modified:
portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java
===================================================================
---
portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java 2009-12-28
07:53:00 UTC (rev 1146)
+++
portal/trunk/component/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboard.java 2009-12-29
02:12:57 UTC (rev 1147)
@@ -20,6 +20,9 @@
package org.exoplatform.dashboard.webui.component;
import org.exoplatform.portal.webui.application.UIGadget;
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -133,9 +136,20 @@
String objectId = context.getRequestParameter(OBJECTID);
String minimized = context.getRequestParameter("minimized");
+ UIDashboardContainer uiDashboardCont =
uiDashboard.getChild(UIDashboardContainer.class);
UIGadget uiGadget =
uiDashboard.getChild(UIDashboardContainer.class).getUIGadget(objectId);
- uiGadget.getProperties().setProperty("minimized", minimized);
- uiDashboard.getChild(UIDashboardContainer.class).save();
+ if (uiGadget.isLossData())
+ {
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
+ uiApp.addMessage(new
ApplicationMessage("UIDashboard.msg.ApplicationNotExisted", null));
+ uiDashboardCont.removeUIGadget(uiGadget.getId());
+ context.addUIComponentToUpdateByAjax(uiDashboard);
+ }
+ else
+ {
+ uiGadget.getProperties().setProperty("minimized", minimized);
+ }
+ uiDashboardCont.save();
context.addUIComponentToUpdateByAjax(uiGadget);
}
}
@@ -150,6 +164,16 @@
String maximize = context.getRequestParameter("maximize");
UIDashboardContainer uiDashboardCont =
uiDashboard.getChild(UIDashboardContainer.class);
UIGadget uiGadget = uiDashboardCont.getUIGadget(objectId);
+ if (uiGadget == null || uiGadget.isLossData())
+ {
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
+ uiApp.addMessage(new
ApplicationMessage("UIDashboard.msg.ApplicationNotExisted", null));
+ if (uiGadget != null)
+ uiDashboardCont.removeUIGadget(uiGadget.getId());
+ uiDashboardCont.save();
+ context.addUIComponentToUpdateByAjax(uiDashboard);
+ return;
+ }
if (maximize.equals("maximize"))
{
uiGadget.setView(UIGadget.CANVAS_VIEW);
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java 2009-12-28
07:53:00 UTC (rev 1146)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/tasks/PreferencesTask.java 2009-12-29
02:12:57 UTC (rev 1147)
@@ -33,8 +33,7 @@
{
/** . */
-// private static final Object NULL_PREFS = new Object();
-
+ // private static final Object NULL_PREFS = new Object();
public static class GetContentId<S> extends PreferencesTask<S> implements
POMTask<String>
{
@@ -86,6 +85,8 @@
public S run(POMSession session) throws Exception
{
Customization<S> customization =
(Customization<S>)session.findCustomizationById(storageId);
+ if (customization == null)
+ return null;
return customization.getVirtualState();
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2009-12-28
07:53:00 UTC (rev 1146)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2009-12-29
02:12:57 UTC (rev 1147)
@@ -29,7 +29,6 @@
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.application.gadget.GadgetApplication;
-import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIComponent;
@@ -212,26 +211,44 @@
return null;
}
}
-
+
@Override
public boolean isRendered()
{
- DataStorage service = getApplicationComponent(DataStorage.class);
try
{
+ DataStorage service = getApplicationComponent(DataStorage.class);
service.load(state, ApplicationType.GADGET);
if (getApplication() == null)
{
- throw new Exception("ApplicationNotExisted");
+ throw new Exception();
}
}
catch (Exception e)
- {
+ {
return false;
}
return super.isRendered();
}
-
+
+ public boolean isLossData()
+ {
+ try
+ {
+ DataStorage service = getApplicationComponent(DataStorage.class);
+ service.load(state, ApplicationType.GADGET);
+ if (getApplication() == null)
+ {
+ throw new Exception();
+ }
+ }
+ catch (Exception e)
+ {
+ return true;
+ }
+ return false;
+ }
+
/**
* Gets GadgetApplication by GadgedRegistryService
*
@@ -381,11 +398,18 @@
org.exoplatform.portal.pom.spi.gadget.Gadget gadget = new
org.exoplatform.portal.pom.spi.gadget.Gadget();
gadget.setUserPref(userPref);
- //
UIGadget uiGadget = event.getSource();
+ if (uiGadget.isLossData())
+ {
+ /*
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
+ uiApp.addMessage(new
ApplicationMessage("UIDashboard.msg.ApplicationNotExisted", null));
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ pcontext.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
+ */
+ return;
+ }
DataStorage service = uiGadget.getApplicationComponent(DataStorage.class);
-
- //
uiGadget.state = service.save(uiGadget.state, gadget);
event.getRequestContext().setResponseComplete(true);
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2009-12-28
07:53:00 UTC (rev 1146)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2009-12-29
02:12:57 UTC (rev 1147)
@@ -74,11 +74,6 @@
import org.gatein.pc.portlet.impl.spi.AbstractSecurityContext;
import org.gatein.pc.portlet.impl.spi.AbstractServerContext;
-import javax.portlet.PortletMode;
-import javax.portlet.WindowState;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -89,10 +84,16 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
+import java.util.Map.Entry;
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.namespace.QName;
+
/** May 19, 2006 */
@ComponentConfig(lifecycle = UIPortletLifecycle.class, template =
"system:/groovy/portal/webui/application/UIPortlet.gtmpl", events = {
@EventConfig(listeners = RenderActionListener.class),
@@ -711,6 +712,10 @@
invocation.setWindowState(org.gatein.pc.api.WindowState.create(getCurrentWindowState().toString()));
StatefulPortletContext<C> preferencesPortletContext = getPortletContext();
+ if (preferencesPortletContext == null)
+ {
+ return null;
+ }
// get the user profile cached in the prc during the start of the request
UserProfile userProfile =
(UserProfile)prc.getAttribute(UserProfileLifecycle.USER_PROFILE_ATTRIBUTE_NAME);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2009-12-28
07:53:00 UTC (rev 1146)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2009-12-29
02:12:57 UTC (rev 1147)
@@ -79,8 +79,7 @@
* modes (if they have to change) as well as a list of Events to be broadcasted to the
other portlets located in the
* same portal page
*/
- static public class ProcessActionActionListener<S, C extends Serializable, I>
extends
- EventListener<UIPortlet<S, C>>
+ static public class ProcessActionActionListener<S, C extends Serializable, I>
extends EventListener<UIPortlet<S, C>>
{
public void execute(Event<UIPortlet<S, C>> event) throws Exception
{
@@ -90,10 +89,11 @@
// set the public render parameters from the request before creating the
invocation
HttpServletRequest request = prcontext.getRequest();
setupPublicRenderParams(uiPortlet, request.getParameterMap());
-
+
//
ActionInvocation actionInvocation = uiPortlet.create(ActionInvocation.class,
prcontext);
-
+ if (actionInvocation == null)
+ return;
//
PortletInvocationResponse portletResponse = uiPortlet.invoke(actionInvocation);
@@ -169,7 +169,7 @@
// update the public render parameters with the changes from the invocation
setupPublicRenderParams(uiPortlet,
navStateResponse.getPublicNavigationalStateUpdates());
-
+
/*
* Handle the events returned by the action output and broadcast a new UI
* event to the ProcessEventsActionListener that will then target the
@@ -298,8 +298,7 @@
* Finally the content is set in the portal response writer or outputstream depending
on the type; the
* processRender() method of the portal is not called as we set the response as
complete
*/
- static public class ServeResourceActionListener<S, C extends Serializable, I>
extends
- EventListener<UIPortlet<S, C>>
+ static public class ServeResourceActionListener<S, C extends Serializable, I>
extends EventListener<UIPortlet<S, C>>
{
public void execute(Event<UIPortlet<S, C>> event) throws Exception
{
@@ -410,7 +409,7 @@
* page (usual layout or webos) which instance can be targeted by the
* event and then process the event on the associated UIPortlet component
*/
- while(events.size() > 0)
+ while (events.size() > 0)
{
javax.portlet.Event nativeEvent = events.remove(0);
QName eventName = nativeEvent.getQName();
@@ -454,7 +453,7 @@
* ProcessEventsActionListener once again
*/
public static <S, C extends Serializable, I> List<javax.portlet.Event>
processEvent(UIPortlet<S, C> uiPortlet,
-
javax.portlet.Event event)
+ javax.portlet.Event event)
{
log.info("Process Event: " + event.getName() + " for portlet: "
+ uiPortlet.getState());
try
@@ -599,7 +598,9 @@
setupPublicRenderParams(uiPortlet, request.getParameterMap());
//set render params
- String navState =
((PortalRequestContext)event.getRequestContext()).getRequestParameter(ExoPortletInvocationContext.NAVIGATIONAL_STATE_PARAM_NAME);
+ String navState =
+ ((PortalRequestContext)event.getRequestContext())
+
.getRequestParameter(ExoPortletInvocationContext.NAVIGATIONAL_STATE_PARAM_NAME);
uiPortlet.setNavigationalState(ParametersStateString.create(navState));
}
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java 2009-12-28
07:53:00 UTC (rev 1146)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java 2009-12-29
02:12:57 UTC (rev 1147)
@@ -111,6 +111,7 @@
UIPortalApplication uiPortalApp =
(UIPortalApplication)prContext.getUIApplication();
UIWorkingWorkspace uiWorkingWS =
uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
+ prContext.setFullRender(true);
return;
}
@@ -128,6 +129,7 @@
UIPortalApplication uiPortalApp =
(UIPortalApplication)prContext.getUIApplication();
UIWorkingWorkspace uiWorkingWS =
uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
+ prContext.setFullRender(true);
return;
}
}
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 2009-12-28
07:53:00 UTC (rev 1146)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2009-12-29
02:12:57 UTC (rev 1147)
@@ -25,7 +25,6 @@
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.PortalProperties;
-import org.exoplatform.portal.pom.data.ModelChange;
import org.exoplatform.portal.resource.SkinService;
import org.exoplatform.portal.webui.application.UIApplicationList;
import org.exoplatform.portal.webui.application.UIPortlet;
@@ -87,7 +86,7 @@
private boolean isCollapse = false;
private boolean isShowControl = true;
-
+
public UIPortalComposer() throws Exception
{
UITabPane uiTabPane = addChild(UITabPane.class, "UIPortalComposerTab",
null);
@@ -169,19 +168,21 @@
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)
{
configService.update(portalConfig);
- } else {
+ }
+ else
+ {
UIApplication uiApp = prContext.getUIApplication();
- uiApp.addMessage(new
ApplicationMessage("UIPortalForm.msg.notExistAnymore", null));
+ uiApp.addMessage(new
ApplicationMessage("UIPortalForm.msg.notExistAnymore", null));
prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
return;
}
@@ -302,10 +303,10 @@
String portalOwner = null;
UIEditInlineWorkspace uiEditWS =
event.getSource().getAncestorOfType(UIEditInlineWorkspace.class);
temp = uiEditWS.getUIComponent();
- if(temp != null && (temp instanceof UIPortal))
+ if (temp != null && (temp instanceof UIPortal))
{
uiPortal = (UIPortal)temp;
- if(uiPortal.getOwnerType().equals(PortalConfig.PORTAL_TYPE))
+ if (uiPortal.getOwnerType().equals(PortalConfig.PORTAL_TYPE))
{
portalOwner = uiPortal.getOwner();
}
@@ -317,13 +318,14 @@
uiPortal = Util.getUIPortal();
portalOwner = Util.getPortalRequestContext().getPortalOwner();
}
-
+
UIPortalApplication uiApp =
uiPortal.getAncestorOfType(UIPortalApplication.class);
UIMaskWorkspace uiMaskWS =
uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
- UIPortalForm portalForm = uiMaskWS.createUIComponent(UIPortalForm.class, null,
"UIPortalForm");
- portalForm.setPortalOwner(portalOwner);
+ UIPortalForm portalForm = uiMaskWS.createUIComponent(UIPortalForm.class, null,
"UIPortalForm");
+ portalForm.setPortalOwner(portalOwner);
portalForm.setBindingBean();
- if(PortalConfig.USER_TYPE.equals(uiPortal.getOwnerType())){
+ if (PortalConfig.USER_TYPE.equals(uiPortal.getOwnerType()))
+ {
portalForm.removeChildById("PermissionSetting");
}
uiMaskWS.setWindowSize(700, -1);
@@ -343,12 +345,12 @@
uiEditWS.getComposer().setEditted(false);
uiEditWS.setRendered(false);
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
- UISiteBody siteBody = uiWorkingWS.findFirstComponentOfType(UISiteBody.class);
-
+ UISiteBody siteBody = uiWorkingWS.findFirstComponentOfType(UISiteBody.class);
+
UIPortal uiPortal = uiWorkingWS.getBackupUIPortal();
- siteBody.setUIComponent(uiPortal);
-
- String uri = uiPortal.getSelectedNode() != null ?
uiPortal.getSelectedNode().getUri() : null;
+ siteBody.setUIComponent(uiPortal);
+
+ String 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);
@@ -553,9 +555,28 @@
{
public void execute(Event<UIPortalComposer> event) throws Exception
{
+ UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
+ UIPortal uiPortal = Util.getUIPortal();
UIEditInlineWorkspace editInlineWS = event.getSource().getParent();
UIWorkingWorkspace uiWorkingWS = editInlineWS.getParent();
UIPortalToolPanel uiToolPanel =
uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
+ UIPage uiPage = uiToolPanel.findFirstComponentOfType(UIPage.class);
+ Page page = (Page)PortalDataMapper.buildModelObject(uiPage);
+ UserPortalConfigService portalConfigService =
+ uiWorkingWS.getApplicationComponent(UserPortalConfigService.class);
+ if (page.getStorageId() != null &&
portalConfigService.getPage(page.getPageId()) == null)
+ {
+ uiPortalApp.addMessage(new
ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{page
+ .getPageId()}, 1));
+ uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
+ PageNodeEvent<UIPortal> pnevent =
+ new PageNodeEvent<UIPortal>(uiPortal,
PageNodeEvent.CHANGE_PAGE_NODE,
+ (uiPortal.getSelectedNode() != null ?
uiPortal.getSelectedNode().getUri() : null));
+ uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ JavascriptManager jsManager =
event.getRequestContext().getJavascriptManager();
+ jsManager.addJavascript("eXo.portal.portalMode=" +
UIPortalApplication.NORMAL_MODE + ";");
+ return;
+ }
UIPortalComposer composer =
uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class).setRendered(false);
composer.setEditted(false);
if (composer.isUsedInWizard())
@@ -568,19 +589,10 @@
uiEvent.broadcast();
return;
}
- UIPage uiPage = uiToolPanel.findFirstComponentOfType(UIPage.class);
- //
- Page page = (Page)PortalDataMapper.buildModelObject(uiPage);
- UserPortalConfigService portalConfigService =
- uiWorkingWS.getApplicationComponent(UserPortalConfigService.class);
-
// Perform mop update
- List<ModelChange> changes = portalConfigService.update(page);
-
+ portalConfigService.update(page);
uiToolPanel.setUIComponent(null);
- UIPortal uiPortal = Util.getUIPortal();
- UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
if (PortalProperties.SESSION_ALWAYS.equals(uiPortal.getSessionAlive()))
{
uiPortalApp.setSessionOpen(true);