List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:org.apache.sqoop.orm.AvroSchemaGenerator.java
private Type toAvroType(String columnName, int sqlType) { Properties mapping = options.getMapColumnJava(); if (mapping.containsKey(columnName)) { String type = mapping.getProperty(columnName); if (LOG.isDebugEnabled()) { LOG.info("Overriding type of column " + columnName + " to " + type); }// www . j a v a2 s. com if (type.equalsIgnoreCase("INTEGER")) { return Type.INT; } if (type.equalsIgnoreCase("LONG")) { return Type.LONG; } if (type.equalsIgnoreCase("BOOLEAN")) { return Type.BOOLEAN; } if (type.equalsIgnoreCase("FLOAT")) { return Type.FLOAT; } if (type.equalsIgnoreCase("DOUBLE")) { return Type.DOUBLE; } if (type.equalsIgnoreCase("STRING")) { return Type.STRING; } if (type.equalsIgnoreCase("BYTES")) { return Type.BYTES; } // Mapping was not found throw new IllegalArgumentException("Cannot convert to AVRO type " + type); } return connManager.toAvroType(tableName, columnName, sqlType); }
From source file:org.onebusaway.webapp.impl.TypedMessagesFactory.java
protected Object createInstance() throws IOException { String name = _messagesClass.getName(); name = "/" + name.replace('.', '/') + ".properties"; InputStream is = _messagesClass.getResourceAsStream(name); if (is == null) throw new IllegalStateException("Unable to find resources: " + name); Properties p = new Properties(); p.load(is);/*from w ww . j a v a 2 s . com*/ for (Method method : _messagesClass.getDeclaredMethods()) { if (!p.containsKey(method.getName())) _log.warn("missing message name: messagesType=" + _messagesClass.getName() + " property=" + method.getName()); } Handler handler = new Handler(p); return Proxy.newProxyInstance(_messagesClass.getClassLoader(), new Class[] { _messagesClass }, handler); }
From source file:jetbrick.template.web.springboot.JetTemplateAutoConfiguration.java
@Bean @ConditionalOnMissingBean(JetTemplateViewResolver.class) public JetTemplateViewResolver jetTemplateViewResolver(JetTemplateProperties properties) { Properties config = properties.getConfig(); if (config == null) { config = new Properties(); }//w ww.ja va 2s .c o m if (!config.containsKey(JetConfig.TEMPLATE_LOADERS)) { config.put(JetConfig.TEMPLATE_LOADERS, ClasspathResourceLoader.class.getName()); } JetTemplateViewResolver resolver = new JetTemplateViewResolver(); resolver.setPrefix(properties.getPrefix()); resolver.setSuffix(properties.getSuffix()); resolver.setCache(properties.isCache()); resolver.setViewNames(properties.getViewNames()); resolver.setContentType(properties.getContentType().toString()); resolver.setOrder(properties.getOrder()); resolver.setConfigProperties(config); resolver.setConfigLocation(properties.getConfigLocation()); return resolver; }
From source file:nl.opengeogroep.filesetsync.client.plugin.SetFileXpathToHttpRequestHeaderPlugin.java
@Override public void beforeStart(Fileset config, SyncJobState state) { updateAllHeaders();// w w w . ja v a 2 s .c o m Map<String, Header> validHeaders = new HashMap(); for (String header : headers.keySet()) { Properties props = headers.get(header); if (props.containsKey("lastValue")) { validHeaders.put(header, new BasicHeader(header, props.getProperty("lastValue"))); } } List<Header> existingHeaders = state.getRequestHeaders(); List<Header> toRemove = new ArrayList(); for (Header existingHeader : existingHeaders) { if (validHeaders.containsKey(existingHeader.getName())) { toRemove.add(existingHeader); } } existingHeaders.removeAll(toRemove); existingHeaders.addAll(validHeaders.values()); }
From source file:mercury.tags.SetInitialLocale.java
@Override public void doTag() throws JspException { try {/*from w w w . j a v a2s . co m*/ PageContext pageContext = (PageContext) getJspContext(); if (pageContext.getServletContext().getAttribute("FIRST_EXECUTION") != null) { pageContext.getServletContext().removeAttribute("FIRST_EXECUTION"); pageContext.getSession().removeAttribute("LAST_VISITED_PAGE"); pageContext.getSession().removeAttribute("MESSAGE_TEXT"); pageContext.getSession().removeAttribute("MESSAGE_LEVEL"); pageContext.getSession().setAttribute("MESSAGE_TEXT", "DIALOG_VOID"); pageContext.getSession().setAttribute("MESSAGE_LEVEL", "NORMAL"); } String lastVisitedPage = (String) pageContext.getSession().getAttribute("LAST_VISITED_PAGE"); if (lastVisitedPage == null || lastVisitedPage.trim().equals("")) { lastVisitedPage = errorJsp; pageContext.getSession().setAttribute("LAST_VISITED_PAGE", lastVisitedPage); } if ((String) pageContext.getSession().getAttribute("I18N") == null) { String locale = pageContext.getRequest().getLocale().toString(); Properties languages = (Properties) pageContext.getServletContext().getAttribute("LANGUAGES"); if (StringUtils.isNotBlank(locale) && languages.containsKey(locale)) { pageContext.getSession().setAttribute("I18N", locale); } else { pageContext.getSession().setAttribute("I18N", defaultLanguage); } } } catch (Exception ex) { log.error(ex.getMessage(), ex); throw new JspException("[mercury.SetInitialLocale.doTag()] Exception: " + ex.getMessage()); } }
From source file:com.coinblesk.server.controller.VersionController.java
/** * Extracts the Version property from the manifest. * * @return the version iff run as war packaged application. Otherwise, * (UNKNOWN) is returned./*from w w w . ja va2 s . com*/ * @throws CoinbleskException */ private String getServerVersion() throws CoinbleskException { // see: build.gradle final String versionKey = "Version"; final String defaultVersion = "(UNKNOWN)"; InputStream inputStream = null; try { inputStream = context.getClassLoader().getResourceAsStream("/META-INF/MANIFEST.MF"); if (inputStream == null) { LOG.warn("Manifest resource not found (inputStream=null, maybe not run as jar file?)."); return defaultVersion; } Properties prop = new Properties(); prop.load(inputStream); if (prop.containsKey(versionKey)) { return prop.getProperty(versionKey, defaultVersion).toString().trim(); } else { LOG.warn("Version key '{}' not foudn in manifest.", versionKey); } } catch (Exception e) { LOG.error("Could not determine version: ", e); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { LOG.debug("Could not close input stream: ", e); } } } return defaultVersion; }
From source file:es.itecban.deployment.resource.taxonomy.DefaultTaxonomyImpl.java
/** * If category is null, then the search will be done in any category * /*from ww w.ja va2 s. c o m*/ * @throws FileNotFoundException */ public boolean isValidType(String type, Category category) { if (category == null) { List<Category> categoryList = this.getRegisteredCategories(); for (Category theCategory : categoryList) { Properties supportedTypes = theCategory.getSupportedTypes(); if (supportedTypes.containsKey(type)) { return true; } } } else { Properties supportedTypes = category.getSupportedTypes(); if (supportedTypes.containsKey(type)) { return true; } } return false; }
From source file:com.meltmedia.cadmium.core.git.GitService.java
/** * Initializes war content directory for a Cadmium war. * @param uri The remote Git repository ssh URI. * @param branch The remote branch to checkout. * @param root The shared content root./*from w w w .ja v a2 s . c o m*/ * @param warName The name of the war file. * @param historyManager The history manager to log the initialization event. * @return A GitService object the points to the freshly cloned Git repository. * @throws RefNotFoundException * @throws Exception */ public static GitService initializeContentDirectory(String uri, String branch, String root, String warName, HistoryManager historyManager, ConfigManager configManager) throws Exception { initializeBaseDirectoryStructure(root, warName); String warDir = FileSystemManager.getChildDirectoryIfExists(root, warName); Properties configProperties = configManager.getDefaultProperties(); GitLocation gitLocation = new GitLocation(uri, branch, configProperties.getProperty("git.ref.sha")); GitService cloned = initializeRepo(gitLocation, warDir, "git-checkout"); try { String renderedContentDir = initializeSnapshotDirectory(warDir, configProperties, "com.meltmedia.cadmium.lastUpdated", "git-checkout", "renderedContent"); boolean hasExisting = configProperties.containsKey("com.meltmedia.cadmium.lastUpdated") && renderedContentDir != null && renderedContentDir.equals(configProperties.getProperty("com.meltmedia.cadmium.lastUpdated")); if (renderedContentDir != null) { configProperties.setProperty("com.meltmedia.cadmium.lastUpdated", renderedContentDir); } configProperties.setProperty("branch", cloned.getBranchName()); configProperties.setProperty("git.ref.sha", cloned.getCurrentRevision()); configProperties.setProperty("repo", cloned.getRemoteRepository()); if (renderedContentDir != null) { String sourceFilePath = renderedContentDir + File.separator + "MET-INF" + File.separator + "source"; if (sourceFilePath != null && FileSystemManager.canRead(sourceFilePath)) { try { configProperties.setProperty("source", FileSystemManager.getFileContents(sourceFilePath)); } catch (Exception e) { log.warn("Failed to read source file {}", sourceFilePath); } } else if (!configProperties.containsKey("source")) { configProperties.setProperty("source", "{}"); } } else if (!configProperties.containsKey("source")) { configProperties.setProperty("source", "{}"); } configManager.persistDefaultProperties(); ExecutorService pool = null; if (historyManager == null) { pool = Executors.newSingleThreadExecutor(); historyManager = new HistoryManager(warDir, pool); } try { if (historyManager != null && !hasExisting) { historyManager.logEvent(EntryType.CONTENT, new GitLocation(cloned.getRemoteRepository(), cloned.getBranchName(), cloned.getCurrentRevision()), "AUTO", renderedContentDir, "", "Initial content pull.", true, true); } } finally { if (pool != null) { pool.shutdownNow(); } } return cloned; } catch (Throwable e) { cloned.close(); throw new Exception(e); } }
From source file:com.meltmedia.cadmium.core.git.GitService.java
/** * Initializes war configuration directory for a Cadmium war. * @param uri The remote Git repository ssh URI. * @param branch The remote branch to checkout. * @param root The shared root.//w w w. ja v a2 s.c o m * @param warName The name of the war file. * @param historyManager The history manager to log the initialization event. * @return A GitService object the points to the freshly cloned Git repository. * @throws RefNotFoundException * @throws Exception */ public static GitService initializeConfigDirectory(String uri, String branch, String root, String warName, HistoryManager historyManager, ConfigManager configManager) throws Exception { initializeBaseDirectoryStructure(root, warName); String warDir = FileSystemManager.getChildDirectoryIfExists(root, warName); Properties configProperties = configManager.getDefaultProperties(); GitLocation gitLocation = new GitLocation(uri, branch, configProperties.getProperty("config.git.ref.sha")); GitService cloned = initializeRepo(gitLocation, warDir, "git-config-checkout"); try { String renderedContentDir = initializeSnapshotDirectory(warDir, configProperties, "com.meltmedia.cadmium.config.lastUpdated", "git-config-checkout", "config"); boolean hasExisting = configProperties.containsKey("com.meltmedia.cadmium.config.lastUpdated") && renderedContentDir != null && renderedContentDir .equals(configProperties.getProperty("com.meltmedia.cadmium.config.lastUpdated")); if (renderedContentDir != null) { configProperties.setProperty("com.meltmedia.cadmium.config.lastUpdated", renderedContentDir); } configProperties.setProperty("config.branch", cloned.getBranchName()); configProperties.setProperty("config.git.ref.sha", cloned.getCurrentRevision()); configProperties.setProperty("config.repo", cloned.getRemoteRepository()); configManager.persistDefaultProperties(); ExecutorService pool = null; if (historyManager == null) { pool = Executors.newSingleThreadExecutor(); historyManager = new HistoryManager(warDir, pool); } try { if (historyManager != null && !hasExisting) { historyManager.logEvent(EntryType.CONFIG, // NOTE: We should integrate the git pointer into this class. new GitLocation(cloned.getRemoteRepository(), cloned.getBranchName(), cloned.getCurrentRevision()), "AUTO", renderedContentDir, "", "Initial config pull.", true, true); } } finally { if (pool != null) { pool.shutdownNow(); } } return cloned; } catch (Throwable e) { cloned.close(); throw new Exception(e); } }
From source file:org.apache.nifi.toolkit.cli.impl.command.AbstractCommand.java
protected boolean isVerbose(final Properties properties) { return properties.containsKey(CommandOption.VERBOSE.getLongName()); }