Java Code Examples for javax.faces.context.FacesContext#getExternalContext()

The following examples show how to use javax.faces.context.FacesContext#getExternalContext() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void getResultsInCSV() {
    logger.info("getResultsInCSV invoked {}", System.getProperty("user.name"));
    try {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();
        externalContext.responseReset();
        String reportName = getExportFileName();
        externalContext.setResponseHeader("Content-Disposition", "attachment; filename=\"" + reportName + "\"");
        OutputStream output = externalContext.getResponseOutputStream();
        statisticsReportHandler.writeReport(output);
        facesContext.responseComplete();
    } catch (Exception e) {
        logger.error("Could not export report", e);
        BeanUtil.addErrorMessage("Could not export report", e.getMessage());
    }
}
 
Example 2
public void getExported() {

		try {

            FacesContext facesContext = FacesContext.getCurrentInstance();
            ExternalContext externalContext = facesContext.getExternalContext();
            externalContext.responseReset();
            externalContext.setResponseContentType("text/csv");
            String reportName = StatisticsUtils.createScriptRunsHistoryName();
            externalContext.setResponseHeader("Content-Disposition", "attachment; filename=\"" + reportName + "\"");
            OutputStream output = externalContext.getResponseOutputStream();
            StatisticsUtils.writeScriptRunsHistory(BeanUtil.getSfContext(), output,
                                                   new ArrayList<>(Arrays.asList(selectedColumns)), lastResult,
                                                   exportWithTCs, exportWithActions, matrixInfo);
            facesContext.responseComplete();

		} catch (IOException e) {

			logger.error("Could not export data to csv file", e);

			BeanUtil.addErrorMessage("Could not export statistics to csv file", "");

		}
	}
 
Example 3
public String getUrlPath(FacesContext context, String pathInfo, String extraPathInfo) {
	ExternalContext externalContext = context.getExternalContext();
	String contextPath = externalContext.getRequestContextPath();
	String servletPath = externalContext.getRequestServletPath();

	StringBuilder b = new StringBuilder();
	b.append(contextPath);
	b.append(servletPath);

	// If there is a path info, use it as part of the URL
	if (StringUtil.isNotEmpty(pathInfo)) {
		b.append("/");
		b.append(pathInfo);
		// the extra path info is only valid in this case
		if (StringUtil.isNotEmpty(extraPathInfo)) {
			b.append("/");
			b.append(extraPathInfo);
		}
	}

	return b.toString();
}
 
Example 4
Source Project: oxAuth   File: GlobalExceptionHandler.java    License: MIT License 6 votes vote down vote up
public void handle() throws FacesException {
    final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();

    while (i.hasNext()) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();

        Throwable t = context.getException();
        final FacesContext fc = FacesContext.getCurrentInstance();
        final ExternalContext externalContext = fc.getExternalContext();
        try {
if (isInvalidSessionStateException(t)) {
             log.error(t.getMessage(), t);
	performRedirect(externalContext, "/error_session.htm");
} else {
             log.error(t.getMessage(), t);
             performRedirect(externalContext, "/error_service.htm");
}
            fc.renderResponse();
        } finally {
            i.remove();
        }
    }
    getWrapped().handle();
}
 
Example 5
Source Project: development   File: ServiceDetailsCtrl.java    License: Apache License 2.0 6 votes vote down vote up
public String redirectToServiceDetails() {
    logger.logDebug("entering redirectToServiceDetails");
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext extContext = context.getExternalContext();
    String viewId = Marketplace.MARKETPLACE_ROOT + "/serviceDetails.jsf";

    try {
        viewId = extContext.getRequestContextPath()
                + viewId
                + ui.getSelectedServiceKeyQueryPart(String.valueOf(model
                        .getSelectedServiceKey()))
                + ui.getMarketplaceIdQueryPart();
        String urlLink = context.getExternalContext().encodeActionURL(
                viewId);
        JSFUtils.redirect(extContext, urlLink);
    } catch (IOException e) {
        extContext.log(
                getClass().getName() + ".redirectToServiceDetails()", e);
    } finally {
        // reset requested key;
        model.setSelectedServiceKey(null);
    }
    return null;
}
 
Example 6
Source Project: BootsFaces-OSP   File: BsfUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This is a trick method to provide navigation from an ajax request (credit by Ryan Lubke)
 * In fact, you can map an action to an UICommand that calls this method and return null.
 * Once the bean sends the redirect, the ajax client receives a message from the server telling the client to redirect to a new page.
 *
 *
 * @param outcome
 * @throws FacesException
 */
// Example:
// <h:form id="form">
// <!-- with basic jsf components -->
// <h:commandButton id="goToPageBtn" value="Go"
// action="#{exampleBean.goToNewPage}">
// <f:ajax execute="@this" render="@none"/>
// </h:commandButton>
//
// <!-- with bootsfaces components -->
// <b:commandButton id="goToPageBtn" value="Go"
// onclick="ajax:exampleBean.goToNewPage();" />
// </h:form>
//
// @ManagedBean
// @RequestScoped
// public class ExampleBean {
// public String goToNewPage() {
// BsfUtils.navigateInAjax("/pages/newPage.xhtml"); return null; }
// }

public static String navigateInAjax(String outcome)
		throws FacesException {
	FacesContext ctx = FacesContext.getCurrentInstance();
	ExternalContext extContext = ctx.getExternalContext();

	String url = extContext.encodeActionURL(
			ctx.getApplication().getViewHandler().getActionURL(
					ctx, outcome));
	try {
		extContext.redirect(url);
	} catch (IOException ioe) {
		throw new FacesException(ioe);
	}
	return null;
}
 
Example 7
Source Project: oxTrust   File: GlobalExceptionHandler.java    License: MIT License 5 votes vote down vote up
public void handle() throws FacesException {
    final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();

    while (i.hasNext()) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();

        Throwable t = context.getException();
        final FacesContext fc = FacesContext.getCurrentInstance();
        final ExternalContext externalContext = fc.getExternalContext();
        try {
if (isSecurityException(t)) {
	performRedirect(externalContext, "/login.htm");
} else if (isConversationException(t)) {
	log.trace(t.getMessage(), t);
	performRedirect(externalContext, "/conversation_error.htm");
} if (isViewExpiredException(t)) {
                storeRequestURI();
                performRedirect(externalContext, "/login.htm");
} else {
	log.trace(t.getMessage(), t);
	performRedirect(externalContext, "/error.htm");
}
            fc.renderResponse();
        } finally {
            i.remove();
        }
    }
    getWrapped().handle();
}
 
Example 8
public String getUrlPath(FacesContext context, String pathInfo, String extraPathInfo) {
       ExternalContext externalContext = context.getExternalContext();
       String contextPath = externalContext.getRequestContextPath();
       String servletPath = externalContext.getRequestServletPath();

       StringBuilder b = new StringBuilder(); 
       b.append(contextPath);
       b.append(servletPath);
       
       // If there is a path info, use it as part of the URL
       if(StringUtil.isNotEmpty(pathInfo)) {
           if(!pathInfo.startsWith("/")) {
               b.append("/");
           }
        b.append(pathInfo);
        // the extra path info is only valid in this case
        if (StringUtil.isNotEmpty(extraPathInfo)) {
        	b.append("/");
        	b.append(extraPathInfo);
        }
       }
       
       //MNIA9UCECY
       String url= b.toString();
       url=DominoUtils.handleProxyPrefix(url);
       
       return url;
}
 
Example 9
public void encodeBegin(FacesContext context, UIComponent component)
  throws IOException {
  if (!component.isRendered()) return;
  ResponseWriter writer = context.getResponseWriter();
  ExternalContext external = context.getExternalContext();
  HttpServletRequest request = (HttpServletRequest) external.getRequest();

  String clientId = component.getClientId(context);
  log.debug("** encodeBegin, clientId = {}", clientId);
  encodeUploadField(writer, clientId, component);
}
 
Example 10
/**
 * Handle the navigation
 * 
 * @param context
 *        The Faces context.
 * @param fromAction
 *        The action string that triggered the action.
 * @param outcome
 *        The logical outcome string, which is the new tool mode, or if null, the mode does not change.
 */
public void handleNavigation(FacesContext context, String fromAction, String outcome)
{
	m_chain.handleNavigation(context, fromAction, outcome);		
	
	ExternalContext exContext = context.getExternalContext();
   HttpSession session = (HttpSession) exContext.getSession(false);

   if (session == null){
     return;
   }
	
	// add previous navigationString (outcome) to session
	session.setAttribute("MC_PREVIOUS_NAV", outcome);
}
 
Example 11
public void entrySelected() {
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext extContext = context.getExternalContext();
    LandingpageEntryModel selectedEntry = findSelectedEntry(model
            .getSelectedEntryKey());
    try {
        JSFUtils.redirect(extContext, selectedEntry.getRedirectUrl());
    } catch (Exception e) {
        extContext.log(getClass().getName() + ".startService()", e);
    } finally {
        // reset requested key;
        model.setSelectedEntryKey(null);
        model.setSelectedCategory(0);
    }
}
 
Example 12
/**
 * Compose the URL for an Ajax partial refresh request related. 
 */
public static String getPartialRefreshUrl(FacesContext context, UIComponent component) {
    ExternalContext ctx = context.getExternalContext();
    String contextPath = ctx.getRequestContextPath();
    String servletPath = ctx.getRequestServletPath();

    StringBuilder b = new StringBuilder();
    b.append(contextPath);
    b.append(servletPath);
    
    // Add the component id
    String ajaxId = component.getClientId(context);
    b.append('?');
    b.append(AjaxUtil.AJAX_COMPID);
    b.append("=");
    b.append(ajaxId);
    
    // Add the view specific id
    String vid = UniqueViewIdManager.getUniqueViewId(context.getViewRoot());
    if(StringUtil.isNotEmpty(vid)) {
        b.append('&');
        b.append(AjaxUtil.AJAX_VIEWID);
        b.append("=");
        b.append(vid);
    }
    
    return b.toString();
}
 
Example 13
Source Project: socialauth   File: SocialAuthPhaseListener.java    License: MIT License 5 votes vote down vote up
/**
 * If the view starts with the view URL provided to the SocialAuth Seam
 * component, this listener assumes that it has been redirected here by the
 * external provider and verifies if the user is authenticated
 */
public void beforePhase(final PhaseEvent event) {

	FacesContext ctx = FacesContext.getCurrentInstance();
	ExternalContext ec = ctx.getExternalContext();
	/*
	 * Parameter 'successUrl' is configured in web.xml and it must be same
	 * there.
	 */
	String successUrl = ec.getInitParameter("successUrl");

	String viewId = Pages.getCurrentViewId();
	String view = successUrl.split("\\.")[0];

	if (viewId == null || !viewId.startsWith(view)) {
		return;
	}

	SocialAuth social = (SocialAuth) Component
			.getInstance(SocialAuth.class);
	try {
		social.connect();
	} catch (Exception e) {
		log.warn(e);
	}
	Pages.handleOutcome(event.getFacesContext(), null, successUrl);

}
 
Example 14
public boolean mediaIsValid() {
  boolean returnValue =true;
  // check if file is too big
  FacesContext context = FacesContext.getCurrentInstance();
  ExternalContext external = context.getExternalContext();
  Long fileSize = (Long)((ServletContext)external.getContext()).getAttribute("TEMP_FILEUPLOAD_SIZE");
  Long maxSize = Long.valueOf(ServerConfigurationService.getInt("samigo.sizeMax", 40960));

  ((ServletContext)external.getContext()).removeAttribute("TEMP_FILEUPLOAD_SIZE");
  if (fileSize!=null){
    float fileSize_float = fileSize.floatValue()/1024;
    int tmp = Math.round(fileSize_float * 10.0f);
    fileSize_float = (float)tmp / 10.0f;
    float maxSize_float = maxSize.floatValue()/1024;
    int tmp0 = Math.round(maxSize_float * 10.0f);
    maxSize_float = (float)tmp0 / 10.0f;

    String err1=(String)ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.DeliveryMessages", "file_upload_error");
    String err2=(String)ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.DeliveryMessages", "file_uploaded");
    String err3=(String)ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.DeliveryMessages", "max_size_allowed");
    String err4=(String)ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.DeliveryMessages", "upload_again");
    String err = err2 + fileSize_float + err3 + maxSize_float + err4;
    context.addMessage("file_upload_error",new FacesMessage(err1));
    context.addMessage("file_upload_error",new FacesMessage(err));
    returnValue = false;
  }
  return returnValue;
}
 
Example 15
public boolean mediaIsValid()
{
  boolean returnValue =true;
  // check if file is too big
  FacesContext context = FacesContext.getCurrentInstance();
  ExternalContext external = context.getExternalContext();
  Long fileSize = (Long)((ServletContext)external.getContext()).getAttribute("TEMP_FILEUPLOAD_SIZE");
  Long maxSize = Long.valueOf(ServerConfigurationService.getString("samigo.sizeMax", "40960"));

  ((ServletContext)external.getContext()).removeAttribute("TEMP_FILEUPLOAD_SIZE");
  if (fileSize!=null){
    float fileSize_float = fileSize.floatValue()/1024;
    int tmp = Math.round(fileSize_float * 10.0f);
    fileSize_float = (float)tmp / 10.0f;
    float maxSize_float = maxSize.floatValue()/1024;
    int tmp0 = Math.round(maxSize_float * 10.0f);
    maxSize_float = (float)tmp0 / 10.0f;

    String err1=(String)ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.DeliveryMessages", "file_upload_error");
    String err2=(String)ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.DeliveryMessages", "file_uploaded");
    String err3=(String)ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.DeliveryMessages", "max_size_allowed");
    String err4=(String)ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.DeliveryMessages", "upload_again");
    String err = err2 + fileSize_float + err3 + maxSize_float + err4;
    context.addMessage("file_upload_error",new FacesMessage(err1));
    context.addMessage("file_upload_error",new FacesMessage(err));
    returnValue = false;
  }
  return returnValue;
}
 
Example 16
public void decode(FacesContext context, UIComponent comp)
{
    UIInput component = (UIInput) comp;
    if (!component.isRendered()) return;

    ExternalContext external = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) external.getRequest();
    String clientId = component.getClientId(context);
    String directory = (String) RendererUtil.getAttribute(context, component, "directory");

    // mark that this component has had decode() called during request
    // processing
    request.setAttribute(clientId + ATTR_REQUEST_DECODED, "true");

    // check for user errors and developer errors
    boolean atDecodeTime = true;
    String errorMessage = checkForErrors(context, component, clientId, atDecodeTime);
    if (errorMessage != null)
    {
        addFacesMessage(context, clientId, errorMessage);
        return;
    }

    // get the file item
    FileItem item = getFileItem(context, component);

    if (item.getName() == null || item.getName().length() == 0)
    {
        if (component.isRequired())
        {
            addFacesMessage(context, clientId, "Please specify a file.");
            component.setValid(false);
        }
        return;
    }

    if (directory == null || directory.length() == 0)
    {
        // just passing on the FileItem as the value of the component, without persisting it.
        component.setSubmittedValue(item);
    }
    else
    {
        // persisting to a permenent file in a directory.
        // pass on the server-side filename as the value of the component.
        File dir = new File(directory);
        String filename = item.getName();
        filename = filename.replace('\\','/'); // replaces Windows path seperator character "\" with "/"
        filename = filename.substring(filename.lastIndexOf("/")+1);
        File persistentFile = new File(dir, filename);
        try
        {
            item.write(persistentFile);
            component.setSubmittedValue(persistentFile.getPath());
        }
        catch (Exception ex)
        {
            throw new FacesException(ex);
        }
     }

}
 
Example 17
public void decode(FacesContext context, UIComponent comp)
{
    UIInput component = (UIInput) comp;
    if (!component.isRendered()) return;

    ExternalContext external = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) external.getRequest();
    String clientId = component.getClientId(context);
    String directory = (String) RendererUtil.getAttribute(context, component, "directory");

    // mark that this component has had decode() called during request
    // processing
    request.setAttribute(clientId + ATTR_REQUEST_DECODED, "true");

    // check for user errors and developer errors
    boolean atDecodeTime = true;
    String errorMessage = checkForErrors(context, component, clientId, atDecodeTime);
    if (errorMessage != null)
    {
        addFacesMessage(context, clientId, errorMessage);
        return;
    }

    // get the file item
    FileItem item = getFileItem(context, component);

    if (item.getName() == null || item.getName().length() == 0)
    {
        if (component.isRequired())
        {
            addFacesMessage(context, clientId, "Please specify a file.");
            component.setValid(false);
        }
        return;
    }

    if (directory == null || directory.length() == 0)
    {
        // just passing on the FileItem as the value of the component, without persisting it.
        component.setSubmittedValue(item);
    }
    else
    {
        // persisting to a permenent file in a directory.
        // pass on the server-side filename as the value of the component.
        File dir = new File(directory);
        String filename = item.getName();
        filename = filename.replace('\\','/'); // replaces Windows path seperator character "\" with "/"
        filename = filename.substring(filename.lastIndexOf("/")+1);
        File persistentFile = new File(dir, filename);
        try
        {
            item.write(persistentFile);
            component.setSubmittedValue(persistentFile.getPath());
        }
        catch (Exception ex)
        {
            throw new FacesException(ex);
        }
     }

}
 
Example 18
/**
 * Check for errors (both developer errors and user errors) - return a
 * user-friendly error message describing the error, or null if there are no
 * errors.
 */
private static String checkForErrors(FacesContext context, UIComponent component,
        String clientId, boolean atDecodeTime)
{
    ExternalContext external = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) external.getRequest();

    UIForm form = null;
    try
    {
    	form = getForm(component);
    }
    catch (IllegalArgumentException e)
    {
    	// there are more than one nested form - thats not OK!
    	return "DEVELOPER ERROR: The <inputFileUpload> tag must be enclosed in just ONE form.  Nested forms confuse the browser.";
    }
    if (form == null || !"multipart/form-data".equals(RendererUtil.getAttribute(context, form, "enctype")))
    {
        return "DEVELOPER ERROR: The <inputFileUpload> tag must be enclosed in a <h:form enctype=\"multipart/form-data\"> tag.";
    }

    // check tag attributes
    String directory = (String) RendererUtil.getAttribute(context, component, "directory");
    if (directory != null && directory.length() != 0)
    {
        // the tag is configured to persist the uploaded files to a directory.
        // check that the specified directory exists, and is writeable
        File dir = new File(directory);
        if (!dir.isDirectory() || !dir.exists())
        {
            return "DEVELOPER ERROR: The directory specified on the <inputFileUpload> tag does not exist or is not writable.\n"
            + "Check the permissions on directory:\n"
            + dir;
        }
    }

    FileItem item = getFileItem(context, component);
    boolean isMultipartRequest = request.getContentType() != null && request.getContentType().startsWith("multipart/form-data");
    boolean wasMultipartRequestFullyParsed = request.getParameter(clientId + ID_HIDDEN_ELEMENT) != null;
    String requestFilterStatus = (String) request.getAttribute("upload.status");
    Object requestFilterUploadLimit = request.getAttribute("upload.limit");
    Exception requestFilterException = (Exception) request.getAttribute("upload.exception");
    boolean wasDecodeAlreadyCalledOnTheRequest = "true".equals(request.getAttribute(clientId + ATTR_REQUEST_DECODED));

    if (wasDecodeAlreadyCalledOnTheRequest && !atDecodeTime)
    {
        // decode() was already called on the request, and we're now at encode() time - so don't do further error checking
        // as the FileItem may no longer be valid.
        return null;
    }

    // at this point, if its not a multipart request, it doesn't have a file and there isn't an error.
    if (!isMultipartRequest) return null;

    // check for user errors
    if ("exception".equals(requestFilterStatus))
    {
        return "An error occured while processing the uploaded file.  The error was:\n"
                + requestFilterException;
    }
    else if ("size_limit_exceeded".equals(requestFilterStatus))
    {
        // the user tried to upload too large a file
        return "The upload size limit of " + requestFilterUploadLimit + "MB has been exceeded.";
    }
    else if (item == null || item.getName() == null || item.getName().length() == 0)
    {
         // The file item will be null if the component was previously not rendered.
         return null;
     }
    else if (item.getSize() == 0)
    {
        return "The filename '"+item.getName()+"' is invalid.  Please select a valid file.";
    }

    if (!wasMultipartRequestFullyParsed)
    {
        return "An error occured while processing the uploaded file.  The error was:\n"
        + "DEVELOPER ERROR: The <inputFileUpload> tag requires a <filter> in web.xml to parse the uploaded file.\n"
        + "Check that the Sakai RequestFilter is properly configured in web.xml.";
    }

    if (item.getName().indexOf("..") >= 0)
    {
        return "The filename '"+item.getName()+"' is invalid.  Please select a valid file.";
    }

    // everything checks out fine! The upload was parsed, and a FileItem
    // exists with a filename and non-zero length
    return null;
}
 
Example 19
Source Project: sailfish-core   File: AuthBean.java    License: Apache License 2.0 3 votes vote down vote up
public void login() throws IOException {

		FacesContext context = FacesContext.getCurrentInstance();
		ExternalContext externalContext = context.getExternalContext();
		HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();

		try {

			request.login(username, password + PasswordHasher.getSalt());

			User user = BeanUtil.getSfContext().getAuthStorage().getUser(username);

			if (user == null) {

                logger.error("User with login [{}] not found in storage!", username);

				BeanUtil.showMessage(FacesMessage.SEVERITY_ERROR,
						"Invalid login/password pair", "");

				return;
			}

			externalContext.getSessionMap().put(BeanUtil.KEY_USER, user);

			externalContext.redirect(originalURL);

		} catch (ServletException e) {

			// Handle unknown username/password in request.login().
            logger.warn("Bad login attempt with username [{}]; message: {}", username, e.getMessage());
			BeanUtil.showMessage(FacesMessage.SEVERITY_ERROR, "Invalid login/password pair", "");

			return;
		}

		logger.info("Successful login for user [{}]", username);
	}
 
Example 20
/**
 * Return the best available mutex for the given session:
 * that is, an object to synchronize on for the given session.
 * <p>Returns the session mutex attribute if available; usually,
 * this means that the HttpSessionMutexListener needs to be defined
 * in {@code web.xml}. Falls back to the Session reference itself
 * if no mutex attribute found.
 * <p>The session mutex is guaranteed to be the same object during
 * the entire lifetime of the session, available under the key defined
 * by the {@code SESSION_MUTEX_ATTRIBUTE} constant. It serves as a
 * safe reference to synchronize on for locking on the current session.
 * <p>In many cases, the Session reference itself is a safe mutex
 * as well, since it will always be the same object reference for the
 * same active logical session. However, this is not guaranteed across
 * different servlet containers; the only 100% safe way is a session mutex.
 * @param fc the FacesContext to find the session mutex for
 * @return the mutex object (never {@code null})
 * @see org.springframework.web.util.WebUtils#SESSION_MUTEX_ATTRIBUTE
 * @see org.springframework.web.util.HttpSessionMutexListener
 */
public static Object getSessionMutex(FacesContext fc) {
	Assert.notNull(fc, "FacesContext must not be null");
	ExternalContext ec = fc.getExternalContext();
	Object mutex = ec.getSessionMap().get(WebUtils.SESSION_MUTEX_ATTRIBUTE);
	if (mutex == null) {
		mutex = ec.getSession(true);
	}
	return mutex;
}