List of usage examples for javax.servlet ServletContext getAttribute
public Object getAttribute(String name);
null
if there is no attribute by that name. From source file:org.apache.hive.http.HttpServer.java
/** * Get the admin ACLs from the given ServletContext and check if the given * user is in the ACL./*from w ww. j a v a 2s . c om*/ * * @param servletContext the context containing the admin ACL. * @param remoteUser the remote user to check for. * @return true if the user is present in the ACL, false if no ACL is set or * the user is not present */ static boolean userHasAdministratorAccess(ServletContext servletContext, String remoteUser) { AccessControlList adminsAcl = (AccessControlList) servletContext.getAttribute(ADMINS_ACL); UserGroupInformation remoteUserUGI = UserGroupInformation.createRemoteUser(remoteUser); return adminsAcl != null && adminsAcl.isUserAllowed(remoteUserUGI); }
From source file:be.fedict.eid.idp.webapp.ProtocolEntryServlet.java
@SuppressWarnings("unchecked") public static Map<String, IdentityProviderProtocolService> findProtocolServices(ServletContext servletContext) throws ServletException { return (Map<String, IdentityProviderProtocolService>) servletContext .getAttribute(PROTOCOL_SERVICES_ATTRIBUTE); }
From source file:be.fedict.eid.idp.webapp.ProtocolEntryServlet.java
@SuppressWarnings("unchecked") public static Map<String, IdentityProviderAttributeService> findAttributeServices(ServletContext servletContext) throws ServletException { return (Map<String, IdentityProviderAttributeService>) servletContext .getAttribute(ATTRIBUTE_SERVICES_ATTRIBUTE); }
From source file:edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder.java
public static void checkIndexOnRootLogin(HttpServletRequest req) { HttpSession session = req.getSession(); ServletContext context = session.getServletContext(); IndexBuilder indexBuilder = (IndexBuilder) context.getAttribute(IndexBuilder.class.getName()); log.debug("Checking if the index is empty"); if (indexBuilder.indexer.isIndexEmpty()) { log.info("Search index is empty. Running a full index rebuild."); indexBuilder.doIndexRebuild();/*from ww w. j a va 2 s. co m*/ } }
From source file:org.hdiv.util.HDIVUtil.java
/** * Return the <code>ISession</code> instance. * /*from ww w. j a v a 2 s . c o m*/ * @param servletContext * @return {@link ISession} instance */ public static ISession getISession(ServletContext servletContext) { ISession session = (ISession) servletContext.getAttribute(ISESSION_SERVLETCONTEXT_KEY); if (session == null) { throw new HDIVException("ISession has not been initialized in servlet context"); } return session; }
From source file:psiprobe.tools.ApplicationUtils.java
/** * Gets the application attributes./*w ww. j ava2s. c om*/ * * @param context the context * @return the application attributes */ public static List<Attribute> getApplicationAttributes(Context context) { List<Attribute> attrs = new ArrayList<>(); ServletContext servletCtx = context.getServletContext(); for (String attrName : Collections.list(servletCtx.getAttributeNames())) { Object attrValue = servletCtx.getAttribute(attrName); Attribute attr = new Attribute(); attr.setName(attrName); attr.setValue(attrValue); attr.setType(ClassUtils.getQualifiedName(attrValue.getClass())); attrs.add(attr); } return attrs; }
From source file:org.hdiv.util.HDIVUtil.java
/** * Returns the servlet context wrapper object. * //from ww w . jav a2 s .co m * @param servletContext * @return IApplication object */ public static IApplication getApplication(ServletContext servletContext) { IApplication app = (IApplication) servletContext.getAttribute(APPLICATION_SERVLETCONTEXT_KEY); if (app == null) { throw new HDIVException("IApplication has not been initialized in servlet context"); } return app; }
From source file:com.concursive.connect.web.modules.upgrade.utils.UpgradeUtils.java
/** * Executes BSH scripts//from w ww . jav a2 s . c om * * @param context the web context to use for finding the file resource * @param db the database connection to use for executing the script against * @param scriptName The resource filename * @throws Exception Description of the Exception */ private static void upgradeBSH(ServletContext context, Connection db, String scriptName) throws Exception { LOG.info("Executing BeanShell script " + scriptName); // Prepare bean shell script, if needed Interpreter script = new Interpreter(); script.set("db", db); // Add the ApplicationPrefs... ApplicationPrefs prefs = (ApplicationPrefs) context.getAttribute(Constants.APPLICATION_PREFS); script.set("prefs", prefs); // Read the script String pathString = scriptName.substring(0, 4); String setupPath = "/WEB-INF/database/common/" + pathString + "/"; InputStream source = context.getResourceAsStream(setupPath + scriptName); BufferedReader in = new BufferedReader(new InputStreamReader(source)); // Execute the script script.eval(in); in.close(); }
From source file:org.hdiv.util.HDIVUtil.java
/** * Return the <code>HDIVConfig</code> object * /*from w ww . ja va 2 s . c o m*/ * @param servletContext * @return {@link HDIVConfig} instance */ public static HDIVConfig getHDIVConfig(ServletContext servletContext) { HDIVConfig hdivConfig = (HDIVConfig) servletContext.getAttribute(HDIVCONFIG_SERVLETCONTEXT_KEY); if (hdivConfig == null) { throw new HDIVException("HDIVConfig has not been initialized in servlet context"); } return hdivConfig; }
From source file:org.hdiv.util.HDIVUtil.java
/** * Return the {@link MessageSource} instance. * //from w ww. j av a 2 s . c om * @param servletContext * @return {@link MessageSource} instance */ public static MessageSource getMessageSource(ServletContext servletContext) { MessageSource msgSource = (MessageSource) servletContext.getAttribute(MESSAGESOURCE_SERVLETCONTEXT_KEY); if (msgSource == null) { throw new HDIVException("MessageSource has not been initialized in servlet context"); } return msgSource; }