use of org.alfresco.web.bean.users.UserPreferencesBean in project acs-community-packaging by Alfresco.
the class AuthenticationHelper method setupThread.
/**
* Does all the stuff you need to do after successfully authenticating/validating a user ticket to set up the request
* thread. A useful utility method for an authentication filter.
*
* @param sc
* the servlet context
* @param req
* the request
* @param res
* the response
*/
public static void setupThread(ServletContext sc, HttpServletRequest req, HttpServletResponse res, boolean useInterfaceLanguage) {
if (logger.isDebugEnabled())
logger.debug("Setting up the request thread.");
// setup faces context
FacesContext fc = Application.inPortalServer() ? AlfrescoFacesPortlet.getFacesContext(req) : FacesHelper.getFacesContext(req, res, sc);
// Set the current locale and language (overriding the one already decoded from the Accept-Language header
if (WebApplicationContextUtils.getRequiredWebApplicationContext(sc).containsBean(Application.BEAN_CONFIG_SERVICE)) {
I18NUtil.setLocale(Application.getLanguage(req.getSession(), Application.getClientConfig(fc).isLanguageSelect() && useInterfaceLanguage));
} else {
Application.getLanguage(req.getSession(), false);
}
if (logger.isDebugEnabled())
logger.debug("The general locale is : " + I18NUtil.getLocale());
// Programatically retrieve the UserPreferencesBean from JSF
UserPreferencesBean userPreferencesBean = (UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
if (logger.isDebugEnabled())
logger.debug("The UserPreferencesBean is : " + userPreferencesBean);
if (userPreferencesBean != null) {
String contentFilterLanguageStr = userPreferencesBean.getContentFilterLanguage();
if (contentFilterLanguageStr != null) {
// Set the locale for the method interceptor for MLText properties
I18NUtil.setContentLocale(I18NUtil.parseLocale(contentFilterLanguageStr));
} else {
// Nothing has been selected, so remove the content filter
I18NUtil.setContentLocale(null);
}
if (logger.isDebugEnabled())
logger.debug("The content locale is : " + I18NUtil.getContentLocale());
}
}
use of org.alfresco.web.bean.users.UserPreferencesBean in project acs-community-packaging by Alfresco.
the class MakeMultilingualEvaluator method evaluate.
public boolean evaluate(Node node) {
FacesContext fc = FacesContext.getCurrentInstance();
UserPreferencesBean userprefs = (UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
// the total number of available languages for the translation have to be greather that 0
int contentFilterLanguagesCount = userprefs.getContentFilterLanguages(false).length;
return (node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false && node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT) == false && contentFilterLanguagesCount > 0);
}
use of org.alfresco.web.bean.users.UserPreferencesBean in project acs-community-packaging by Alfresco.
the class UILanguageSelector method createList.
/**
* Creates the list of SelectItem components to represent the list
* of Langages the user can select from
*
* @return List of SelectItem components
*/
protected SelectItem[] createList() {
FacesContext fc = FacesContext.getCurrentInstance();
SpaceUsersBean spaceUserBean = (SpaceUsersBean) FacesHelper.getManagedBean(fc, "SpaceUsersBean");
UserPreferencesBean userPreferencesBean = (UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
// get the node ref
NodeRef nodeRef = spaceUserBean.getNode().getNodeRef();
if (this.onlyAvailableLanguages) {
return userPreferencesBean.getAvailablesContentFilterLanguages(nodeRef, this.returnCurrentLanguage);
} else {
return userPreferencesBean.getContentFilterLanguages(false);
}
}
use of org.alfresco.web.bean.users.UserPreferencesBean in project acs-community-packaging by Alfresco.
the class AddTranslationEvaluator method evaluate.
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node) {
boolean isNodeMultililingal = node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
boolean isMLContainer = node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
// the node must be multiligual (translation or ml container)
if (isNodeMultililingal || isMLContainer) {
FacesContext fc = FacesContext.getCurrentInstance();
// where the pivot translation is located in
if (MultilingualUtils.canAddChildrenToPivotSpace(node, fc)) {
MultilingualContentService mlservice = (MultilingualContentService) FacesHelper.getManagedBean(fc, "MultilingualContentService");
UserPreferencesBean userprefs = (UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
// the number of translation of this document
int availableTranslationCount = mlservice.getTranslations(node.getNodeRef()).size();
// the total number of available languages for the translation
int contentFilterLanguagesCount = userprefs.getContentFilterLanguages(false).length;
// the number of translation must be < to the total number of available language for the content filter
return (availableTranslationCount < contentFilterLanguagesCount);
} else {
return false;
}
} else {
return false;
}
}
Aggregations