Merge from HEAD to WCM-DEV2.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3659 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-02 18:19:00 +00:00
parent 3b1d6b89f5
commit cc6af1a45c
100 changed files with 4941 additions and 1298 deletions

View File

@@ -29,8 +29,10 @@ import org.alfresco.config.ConfigService;
import org.alfresco.web.app.servlet.ExternalAccessServlet;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.dialog.DialogManager;
import org.alfresco.web.bean.dialog.DialogState;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.wizard.WizardManager;
import org.alfresco.web.bean.wizard.WizardState;
import org.alfresco.web.config.DialogsConfigElement;
import org.alfresco.web.config.NavigationConfigElement;
import org.alfresco.web.config.NavigationElementReader;
@@ -47,9 +49,9 @@ import org.apache.commons.logging.LogFactory;
public class AlfrescoNavigationHandler extends NavigationHandler
{
public final static String OUTCOME_SEPARATOR = ":";
public final static String DIALOG_PREXIX = "dialog" + OUTCOME_SEPARATOR;
public final static String DIALOG_PREFIX = "dialog" + OUTCOME_SEPARATOR;
public final static String WIZARD_PREFIX = "wizard" + OUTCOME_SEPARATOR;
public final static String CLOSE_DIALOG_OUTCOME = DIALOG_PREXIX + "close";
public final static String CLOSE_DIALOG_OUTCOME = DIALOG_PREFIX + "close";
public final static String CLOSE_WIZARD_OUTCOME = WIZARD_PREFIX + "close";
protected final static String CONFIG_NAV_BEAN = "NavigationBean";
@@ -135,7 +137,7 @@ public class AlfrescoNavigationHandler extends NavigationHandler
{
boolean dialog = false;
if (outcome != null && outcome.startsWith(DIALOG_PREXIX))
if (outcome != null && outcome.startsWith(DIALOG_PREFIX))
{
dialog = true;
}
@@ -589,16 +591,51 @@ public class AlfrescoNavigationHandler extends NavigationHandler
// or any overridden outcome that may be present
if (getViewStack(context).empty() == false)
{
String newViewId = (String)getViewStack(context).pop();
// is there an overidden outcome?
String overriddenOutcome = getOutcomeOverride(outcome);
if (overriddenOutcome == null)
{
// there isn't an overidden outcome so go back to the previous view
if (logger.isDebugEnabled())
logger.debug("Closing " + closingItem + ", going back to view id: " + newViewId);
logger.debug("Closing " + closingItem + ", going back to previous page");
// if the top of the stack is not a dialog or wizard just get the
// view id and navigate back to it.
// if the top of the stack is a dialog or wizard retrieve the state
// and setup the appropriate manager with that state, then get the
// appropriate container page and navigate to it.
Object topOfStack = getViewStack(context).pop();
if (logger.isDebugEnabled())
logger.debug("Popped item from the top of the view stack: " + topOfStack);
String newViewId = null;
if (topOfStack instanceof String)
{
newViewId = (String)topOfStack;
}
else if (topOfStack instanceof DialogState)
{
// restore the dialog state and get the dialog container viewId
Application.getDialogManager().restoreState((DialogState)topOfStack);
newViewId = getDialogContainer(context);
}
else if (topOfStack instanceof WizardState)
{
// restore the wizard state and get the wizard container viewId
Application.getWizardManager().restoreState((WizardState)topOfStack);
newViewId = getWizardContainer(context);
}
else
{
if (logger.isWarnEnabled())
logger.warn("Invalid object found on view stack: " + topOfStack);
}
// go to the appropraite page
goToView(context, newViewId);
}
else
@@ -656,33 +693,66 @@ public class AlfrescoNavigationHandler extends NavigationHandler
*
* @param context FacesContext
*/
@SuppressWarnings("unchecked")
protected void addCurrentViewToStack(FacesContext context)
{
// if we are opening a wizard or dialog push the current view
// id on to the stack, but only if it is different than the
// current view at the top (you can't launch a dialog from
// the same page 2 times in a row!)
// if the current viewId is either the dialog or wizard container page
// we need to save the state of the current dialog or wizard to the stack
// TODO: This wouldn't happen if we could be sure a dialog is
// ALWAYS exited properly, look into a way of ensuring
// dialogs get closed if a user navigates away from the page,
// would a PhaseListener help in any way??
// If the current view is a normal page and it is not the same as the
// view currently at the top of the stack (you can't launch a dialog from
// the same page 2 times in a row so it must mean the user navigated away
// from the first dialog) just add the viewId to the stack
// work out what to add to the stack
String viewId = context.getViewRoot().getViewId();
if (getViewStack(context).empty() ||
viewId.equals(getViewStack(context).peek()) == false)
String dialogContainer = getDialogContainer(context);
String wizardContainer = getWizardContainer(context);
Object objectForStack = null;
if (viewId.equals(dialogContainer))
{
getViewStack(context).push(viewId);
if (logger.isDebugEnabled())
logger.debug("Pushed current view to stack: " + viewId);
DialogManager dlgMgr = Application.getDialogManager();
objectForStack = dlgMgr.getState();
}
else if (viewId.equals(wizardContainer))
{
WizardManager wizMgr = Application.getWizardManager();
objectForStack = wizMgr.getState();
}
else
{
if (getViewStack(context).empty() == false && logger.isDebugEnabled())
objectForStack = viewId;
}
// if the stack is currently empty add the item
Stack stack = getViewStack(context);
if (stack.empty())
{
stack.push(objectForStack);
if (logger.isDebugEnabled())
logger.debug("Pushed item to view stack: " + objectForStack);
}
else
{
// if the item to go on to the stack and the top of
// stack are both Strings and equals to each other
// don't add anything to the stack to stop it
// growing unecessarily
Object topOfStack = stack.peek();
if (objectForStack instanceof String &&
topOfStack instanceof String &&
topOfStack.equals(objectForStack))
{
logger.debug("current view is already top the view stack!");
if (logger.isDebugEnabled())
logger.debug("current view is already top of the view stack!");
}
else
{
stack.push(objectForStack);
if (logger.isDebugEnabled())
logger.debug("Pushed item to view stack: " + objectForStack);
}
}
}
@@ -725,13 +795,13 @@ public class AlfrescoNavigationHandler extends NavigationHandler
* the users session, will never be null
*/
@SuppressWarnings("unchecked")
private Stack<String> getViewStack(FacesContext context)
private Stack getViewStack(FacesContext context)
{
Stack<String> viewStack = (Stack)context.getExternalContext().getSessionMap().get(VIEW_STACK);
Stack viewStack = (Stack)context.getExternalContext().getSessionMap().get(VIEW_STACK);
if (viewStack == null)
{
viewStack = new Stack<String>();
viewStack = new Stack();
context.getExternalContext().getSessionMap().put(VIEW_STACK, viewStack);
}

View File

@@ -0,0 +1,143 @@
package org.alfresco.web.app;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.VariableResolver;
import org.alfresco.config.Config;
import org.alfresco.config.ConfigService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.jsf.DelegatingVariableResolver;
/**
* JSF VariableResolver that first delegates to the Spring JSF variable
* resolver. The sole purpose of this variable resolver is to look out
* for the <code>Container</code> variable. If this variable is encountered
* the current viewId is examined. If the current viewId matches the
* configured dialog or wizard container the appropriate manager object is
* returned i.e. DialogManager or WizardManager.
*
* <p>Configure this resolver in your <code>faces-config.xml</code> file as follows:
*
* <pre>
* &lt;application&gt;
* ...
* &lt;variable-resolver&gt;org.alfresco.web.app.AlfrescoVariableResolver&lt;/variable-resolver&gt;
* &lt;/application&gt;</pre>
*
* @see org.alfresco.web.bean.dialog.DialogManager
* @see org.alfresco.web.bean.wizard.WizardManager
* @author gavinc
*/
public class AlfrescoVariableResolver extends DelegatingVariableResolver
{
protected String dialogContainer = null;
protected String wizardContainer = null;
private static final String CONTAINER = "Container";
private static final Log logger = LogFactory.getLog(AlfrescoVariableResolver.class);
/**
* Creates a new VariableResolver.
*
* @param originalVariableResolver The original variable resolver
*/
public AlfrescoVariableResolver(VariableResolver originalVariableResolver)
{
super(originalVariableResolver);
}
/**
* Resolves the variable with the given name.
* <p>
* This implementation will first delegate to the Spring variable resolver.
* If the variable is not found by the Spring resolver and the variable name
* is <code>Container</code> the current viewId is examined.
* If the current viewId matches the configured dialog or wizard container
* the appropriate manager object is returned i.e. DialogManager or WizardManager.
*
* @param context FacesContext
* @param name The name of the variable to resolve
*/
public Object resolveVariable(FacesContext context, String name)
throws EvaluationException
{
Object variable = super.resolveVariable(context, name);
if (variable == null)
{
// if the variable was not resolved see if the name is "Container"
if (name.equals(CONTAINER))
{
// get the current view id and the configured dialog and wizard
// container pages
String viewId = context.getViewRoot().getViewId();
String dialogContainer = getDialogContainer(context);
String wizardContainer = getWizardContainer(context);
// see if we are currently in a wizard or a dialog
if (viewId.equals(dialogContainer))
{
variable = Application.getDialogManager();
}
else if (viewId.equals(wizardContainer))
{
variable = Application.getWizardManager();
}
if (variable != null && logger.isDebugEnabled())
{
logger.debug("Resolved 'Container' variable to: " + variable);
}
}
}
return variable;
}
/**
* Retrieves the configured dialog container page
*
* @param context FacesContext
* @return The container page
*/
protected String getDialogContainer(FacesContext context)
{
if (this.dialogContainer == null)
{
ConfigService configSvc = Application.getConfigService(context);
Config globalConfig = configSvc.getGlobalConfig();
if (globalConfig != null)
{
this.dialogContainer = globalConfig.getConfigElement("dialog-container").getValue();
}
}
return this.dialogContainer;
}
/**
* Retrieves the configured wizard container page
*
* @param context FacesContext
* @return The container page
*/
protected String getWizardContainer(FacesContext context)
{
if (this.wizardContainer == null)
{
ConfigService configSvc = Application.getConfigService(context);
Config globalConfig = configSvc.getGlobalConfig();
if (globalConfig != null)
{
this.wizardContainer = globalConfig.getConfigElement("wizard-container").getValue();
}
}
return this.wizardContainer;
}
}

View File

@@ -33,6 +33,7 @@ import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.UnavailableException;
import org.alfresco.config.ConfigService;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.service.cmr.security.AuthenticationService;
@@ -43,7 +44,9 @@ import org.alfresco.web.app.servlet.AuthenticationStatus;
import org.alfresco.web.bean.ErrorBean;
import org.alfresco.web.bean.FileUploadBean;
import org.alfresco.web.bean.LoginBean;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.User;
import org.alfresco.web.config.ClientConfigElement;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.portlet.PortletFileUpload;
@@ -259,7 +262,18 @@ public class AlfrescoFacesPortlet extends MyFacesGenericPortlet
// perform the forward to the page processed by the Faces servlet
response.setContentType("text/html");
request.getPortletSession().setAttribute(PortletUtil.PORTLET_REQUEST_FLAG, "true");
nonFacesRequest(request, response, "/jsp/browse/browse.jsp");
// get the start location as configured by the web-client config
ConfigService configService = (ConfigService)ctx.getBean("webClientConfigService");
ClientConfigElement configElement = (ClientConfigElement)configService.getGlobalConfig().getConfigElement("client");
if (NavigationBean.LOCATION_MYALFRESCO.equals(configElement.getInitialLocation()))
{
nonFacesRequest(request, response, "/jsp/dashboards/container.jsp");
}
else
{
nonFacesRequest(request, response, "/jsp/browse/browse.jsp");
}
}
else
{

View File

@@ -77,7 +77,6 @@ public abstract class BaseServlet extends HttpServlet
validRedirectJSPs.add("/jsp/forums/forums.jsp");
validRedirectJSPs.add("/jsp/users/users.jsp");
validRedirectJSPs.add("/jsp/trashcan/trash-list.jsp");
validRedirectJSPs.add("/jsp/dashboards/container.jsp");
}
private static Log logger = LogFactory.getLog(BaseServlet.class);
@@ -156,10 +155,15 @@ public abstract class BaseServlet extends HttpServlet
throws IOException
{
// authentication failed - so end servlet execution and redirect to login page
// also save the full requested URL so the login page knows where to redirect too later
res.sendRedirect(req.getContextPath() + FACES_SERVLET + Application.getLoginPage(sc));
// save the full requested URL so the login page knows where to redirect too later
String uri = req.getRequestURI();
String url = uri + (req.getQueryString() != null ? ("?" + req.getQueryString()) : "");
String url = uri;
if (req.getQueryString() != null && req.getQueryString().length() != 0)
{
url += "?" + req.getQueryString();
}
if (uri.indexOf(req.getContextPath() + FACES_SERVLET) != -1)
{
// if we find a JSF servlet reference in the URI then we need to check if the rest of the