List of usage examples for org.springframework.web.jsf FacesContextUtils getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc) throws IllegalStateException
From source file:org.alfresco.web.app.servlet.BaseServlet.java
/** * Resolves the given path elements to a NodeRef in the current repository * /*from www. j a v a2 s.c om*/ * @param context Faces context * @param args The elements of the path to lookup * @param decode True to decode the arg from UTF-8 format, false for no decoding */ public static NodeRef resolveWebDAVPath(FacesContext context, String[] args, boolean decode) { WebApplicationContext wc = FacesContextUtils.getRequiredWebApplicationContext(context); return resolveWebDAVPath(wc, args, decode); }
From source file:org.alfresco.web.bean.generator.BaseComponentGenerator.java
private DataDictionary getDataDictionary(FacesContext context) { if (this.dataDictionary == null) { this.dataDictionary = (DataDictionary) FacesContextUtils.getRequiredWebApplicationContext(context) .getBean(Application.BEAN_DATA_DICTIONARY); }//from ww w .ja v a 2 s .c om return this.dataDictionary; }
From source file:org.alfresco.web.bean.repository.Repository.java
/** * Returns a company root node reference object. * /* w ww. j ava 2 s . c om*/ * @return The NodeRef object */ public static NodeRef getCompanyRoot(final FacesContext context) { final String currentUserName = Application.getCurrentUser(context).getUserName(); // note: run in context of System user using tenant-specific store // so that Company Root can be returned, even if the user does not have // permission to access the Company Root (including, for example, the Guest user) return AuthenticationUtil.runAs(new RunAsWork<NodeRef>() { public NodeRef doWork() throws Exception { ServiceRegistry sr = getServiceRegistry(context); TenantService tenantService = (TenantService) FacesContextUtils .getRequiredWebApplicationContext(context).getBean("tenantService"); // get store ref (from config) StoreRef storeRef = tenantService.getName(currentUserName, Repository.getStoreRef()); // get root path (from config) String rootPath = Application.getRootPath(context); return getCompanyRoot(sr.getNodeService(), sr.getSearchService(), sr.getNamespaceService(), storeRef, rootPath); } }, AuthenticationUtil.getSystemUserName()); }
From source file:org.alfresco.web.bean.repository.Repository.java
/** * Resolve a Path by converting each element into its display NAME attribute. * Note: This method resolves path regardless access permissions. * Fixes the UI part of the ETWOONE-214 and ETWOONE-238 issues * /* w ww . j a v a 2 s. c o m*/ * @param path Path to convert * @param separator Separator to user between path elements * @param prefix To prepend to the path * * @return Path converted using NAME attribute on each element */ public static String getNamePathEx(FacesContext context, final Path path, final NodeRef rootNode, final String separator, final String prefix) { String result = null; RetryingTransactionHelper transactionHelper = getRetryingTransactionHelper(context); transactionHelper.setMaxRetries(1); final NodeService runtimeNodeService = (NodeService) FacesContextUtils .getRequiredWebApplicationContext(context).getBean("nodeService"); result = transactionHelper.doInTransaction(new RetryingTransactionCallback<String>() { public String execute() throws Throwable { return getNamePath(runtimeNodeService, path, rootNode, separator, prefix); } }); return result; }
From source file:org.alfresco.web.bean.repository.Repository.java
/** * Return the Repository Service Registry * /* www. ja va 2 s . co m*/ * @param context Faces Context * @return the Service Registry */ public static ServiceRegistry getServiceRegistry(FacesContext context) { if (serviceRegistry == null) { serviceRegistry = (ServiceRegistry) FacesContextUtils.getRequiredWebApplicationContext(context) .getBean(ServiceRegistry.SERVICE_REGISTRY); } return serviceRegistry; }
From source file:org.alfresco.web.bean.repository.Repository.java
/** * Return the Configurable Service/*from w w w . ja v a2 s .c o m*/ * * @return the configurable service */ public static ConfigurableService getConfigurableService(FacesContext context) { return (ConfigurableService) FacesContextUtils.getRequiredWebApplicationContext(context) .getBean("ConfigurableService"); }
From source file:org.alfresco.web.bean.repository.Repository.java
/** * Return the Metadata Extracter Registry * /*from w w w. ja va2 s . co m*/ * @param context Faces Context * @return the MetadataExtracterRegistry */ public static MetadataExtracterRegistry getMetadataExtracterRegistry(FacesContext context) { return (MetadataExtracterRegistry) FacesContextUtils.getRequiredWebApplicationContext(context) .getBean(METADATA_EXTACTER_REGISTRY); }
From source file:org.alfresco.web.bean.repository.Repository.java
/** * Query a list of Person type nodes from the repo * It is currently assumed that all Person nodes exist below the Repository root node * // w ww .java 2 s .co m * @param context Faces Context * @param nodeService The node service * @param searchService The search service, which is ignored * @return List of Person node objects * @deprecated Use {@link #getUsers(FacesContext, NodeService, PersonService)} instead */ public static List<Node> getUsers(FacesContext context, NodeService nodeService, SearchService searchService) { PersonService personService = (PersonService) FacesContextUtils.getRequiredWebApplicationContext(context) .getBean("personService"); return getUsers(context, nodeService, personService); }
From source file:org.alfresco.web.bean.repository.Repository.java
/** * @return true if we are currently the special Guest user *//*from ww w .j a va2 s . com*/ public static boolean getIsGuest(FacesContext context) { TenantService tenantService = (TenantService) FacesContextUtils.getRequiredWebApplicationContext(context) .getBean("tenantService"); String userName = Application.getCurrentUser(context).getUserName(); return tenantService.getBaseNameUser(userName).equalsIgnoreCase(AuthenticationUtil.getGuestUserName()); }
From source file:org.alfresco.web.bean.wcm.AVMUtil.java
public static String getPreviewURI(String storeId, String assetPath) { if (!deprecatedPreviewURIGeneratorChecked) { if (deprecatedPreviewURIGenerator == null) { // backwards compatibility - will hide new implementation, until custom providers/context are migrated WebApplicationContext wac = FacesContextUtils .getRequiredWebApplicationContext(FacesContext.getCurrentInstance()); if (wac.containsBean(SPRING_BEAN_NAME_PREVIEW_URI_SERVICE)) { // if the bean is present retrieve it deprecatedPreviewURIGenerator = (PreviewURIService) wac .getBean(SPRING_BEAN_NAME_PREVIEW_URI_SERVICE, PreviewURIService.class); logger.warn("Found deprecated '" + SPRING_BEAN_NAME_PREVIEW_URI_SERVICE + "' config - which will be used instead of new 'WCMPreviewURIService' until migrated (changing web project preview provider will have no effect)"); }/* w w w . j a v a2 s .c om*/ } deprecatedPreviewURIGeneratorChecked = true; } if (deprecatedPreviewURIGenerator != null) { return deprecatedPreviewURIGenerator.getPreviewURI(storeId, assetPath); } return getPreviewURIService().getPreviewURI(storeId, assetPath); }