List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:io.dockstore.webservice.helpers.Helper.java
/** * Refreshes user's containers/*from w w w . ja va 2 s . c o m*/ * * @param userId * @param client * @param objectMapper * @param userDAO * @param toolDAO * @param tokenDAO * @param tagDAO * @param fileDAO * @return list of updated containers */ @SuppressWarnings("checkstyle:parameternumber") public static List<Tool> refresh(final Long userId, final HttpClient client, final ObjectMapper objectMapper, final UserDAO userDAO, final ToolDAO toolDAO, final TokenDAO tokenDAO, final TagDAO tagDAO, final FileDAO fileDAO) { List<Tool> dbTools = new ArrayList(getContainers(userId, userDAO));// toolDAO.findByUserId(userId); // Get user's quay and git tokens List<Token> tokens = tokenDAO.findByUserId(userId); Token quayToken = extractToken(tokens, TokenType.QUAY_IO.toString()); Token githubToken = extractToken(tokens, TokenType.GITHUB_COM.toString()); Token bitbucketToken = extractToken(tokens, TokenType.BITBUCKET_ORG.toString()); // with Docker Hub support it is now possible that there is no quayToken if (githubToken == null) { LOG.info("GIT token not found!"); throw new CustomWebApplicationException("Git token not found.", HttpStatus.SC_CONFLICT); } if (bitbucketToken == null) { LOG.info("WARNING: BITBUCKET token not found!"); } if (quayToken == null) { LOG.info("WARNING: QUAY token not found!"); } ImageRegistryFactory factory = new ImageRegistryFactory(client, objectMapper, quayToken); final List<ImageRegistryInterface> allRegistries = factory.getAllRegistries(); List<String> namespaces = new ArrayList<>(); // TODO: figure out better approach, for now just smash together stuff from DockerHub and quay.io for (ImageRegistryInterface anInterface : allRegistries) { namespaces.addAll(anInterface.getNamespaces()); } List<Tool> apiTools = new ArrayList<>(); for (ImageRegistryInterface anInterface : allRegistries) { apiTools.addAll(anInterface.getContainers(namespaces)); } // TODO: when we get proper docker hub support, get this above // hack: read relevant containers from database User currentUser = userDAO.findById(userId); List<Tool> findByMode = toolDAO.findByMode(ToolMode.MANUAL_IMAGE_PATH); findByMode.removeIf(test -> !test.getUsers().contains(currentUser)); apiTools.addAll(findByMode); // ends up with docker image path -> quay.io data structure representing builds final Map<String, ArrayList<?>> mapOfBuilds = new HashMap<>(); for (final ImageRegistryInterface anInterface : allRegistries) { mapOfBuilds.putAll(anInterface.getBuildMap(apiTools)); } // end up with key = path; value = list of tags // final Map<String, List<Tag>> tagMap = getWorkflowVersions(client, allRepos, objectMapper, quayToken, bitbucketToken, githubToken, // mapOfBuilds); removeContainersThatCannotBeUpdated(dbTools); final User dockstoreUser = userDAO.findById(userId); // update information on a container by container level updateContainers(apiTools, dbTools, dockstoreUser, toolDAO); userDAO.clearCache(); final List<Tool> newDBTools = getContainers(userId, userDAO); // update information on a tag by tag level final Map<String, List<Tag>> tagMap = getTags(client, newDBTools, objectMapper, quayToken, mapOfBuilds); updateTags(newDBTools, client, toolDAO, tagDAO, fileDAO, githubToken, bitbucketToken, tagMap); userDAO.clearCache(); return getContainers(userId, userDAO); }
From source file:io.appform.nautilus.funnel.administration.TenancyManager.java
private void updateMappingsForType(GetMappingsResponse response, ObjectCursor<String> index, Map<String, Map<String, String>> mappings, Class<?> entity) throws Exception { final String typeName = TypeUtils.typeName(entity); if (!mappings.containsKey(typeName)) { mappings.put(typeName, Maps.<String, String>newHashMap()); }/* w w w. j a va 2 s . c o m*/ Map<String, String> mappingsForType = mappings.get(typeName); mappingsForType.putAll(readMappings(response, index, typeName)); }
From source file:com.neophob.sematrix.gui.callback.GuiState.java
/** * convert a list of string to a string string map * @param o// w ww . ja v a 2 s. c om * @return */ public void updateState(List<?> o) { Map<String, String> newState = new HashMap<String, String>(); newState.putAll(state); for (Object obj : o) { String s = (String) obj; String[] tmp = s.split(" "); if (tmp.length > 1) { newState.put(tmp[0], tmp[1]); } else { newState.put(tmp[0], ""); } } diff = getDifference(newState); state = newState; }
From source file:com.revolsys.ui.web.config.JexlHttpServletRequestContext.java
@Override public Map getVars() { return new AbstractMap() { @Override/*from w ww. j a va 2 s . c o m*/ public Set entrySet() { final Map map = new HashMap(); map.putAll(JexlHttpServletRequestContext.this.request.getParameterMap()); for (final Enumeration names = JexlHttpServletRequestContext.this.request.getAttributeNames(); names .hasMoreElements();) { final String name = (String) names.nextElement(); map.put(name, JexlHttpServletRequestContext.this.request.getAttribute(name)); } if (JexlHttpServletRequestContext.this.servletContext != null) { for (final Enumeration names = JexlHttpServletRequestContext.this.servletContext .getAttributeNames(); names.hasMoreElements();) { final String name = (String) names.nextElement(); map.put(name, JexlHttpServletRequestContext.this.servletContext.getAttribute(name)); } } return map.entrySet(); } @Override public Object get(final Object key) { if (key.equals("request")) { return JexlHttpServletRequestContext.this.request; } else if (key.equals("requestURI")) { return JexlHttpServletRequestContext.this.urlPathHelper .getOriginatingRequestUri(JexlHttpServletRequestContext.this.request); } final String keyString = key.toString(); Object value = null; if (JexlHttpServletRequestContext.this.servletContext != null) { value = JexlHttpServletRequestContext.this.servletContext.getAttribute(keyString); } if (value == null) { value = JexlHttpServletRequestContext.this.request.getAttribute(keyString); if (value == null) { value = JexlHttpServletRequestContext.this.request.getParameter(keyString); } } if (value == null) { return ""; } else { return value; } } }; }
From source file:eu.supersede.fe.multitenant.MultiTenancyJpaConfiguration.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) { if (dataSource == null) { return null; }//from ww w .j ava 2 s . c o m Map<String, Object> hibernateProps = new LinkedHashMap<>(); hibernateProps.putAll(jpaProperties.getHibernateProperties(dataSource)); hibernateProps.put(Environment.MULTI_TENANT, MultiTenancyStrategy.DATABASE); hibernateProps.put(Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider); hibernateProps.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolver); hibernateProps.put(Environment.DIALECT, "org.hibernate.dialect.PostgreSQLDialect"); String HBM2DDL_AUTO = env.getProperty(HBM2DDL_AUTO_PROPERTY); if (HBM2DDL_AUTO != null) { hibernateProps.put(Environment.HBM2DDL_AUTO, HBM2DDL_AUTO); } Set<String> packages = new HashSet<>(); String[] tmp = MODELS_PACKAGES.split(","); for (String t : tmp) { packages.add(t.trim()); } packages.add("eu.supersede.fe.notification.model"); return builder.dataSource(dataSource).packages(packages.toArray(new String[packages.size()])) .properties(hibernateProps).jta(false).build(); }
From source file:bboss.org.apache.velocity.runtime.resource.ResourceCacheImpl.java
/** * @see bboss.org.apache.velocity.runtime.resource.ResourceCache#initialize(bboss.org.apache.velocity.runtime.RuntimeServices) *///from w w w . jav a 2 s .co m public void initialize(RuntimeServices rs) { rsvc = rs; int maxSize = rsvc.getInt(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE, 89); if (maxSize > 0) { // Create a whole new Map here to avoid hanging on to a // handle to the unsynch'd LRUMap for our lifetime. Map lruCache = Collections.synchronizedMap(new LRUMap(maxSize)); lruCache.putAll(cache); cache = lruCache; } rsvc.getLog().debug( "ResourceCache: initialized (" + this.getClass() + ") with " + cache.getClass() + " cache map."); }
From source file:com.jaspersoft.jasperserver.api.metadata.user.service.impl.RequestAuthenticationProcessingFilter.java
protected Map obtainRequestParameters(HttpServletRequest request) { Map result = new HashMap(); result.putAll(request.getParameterMap()); Enumeration attrs = request.getAttributeNames(); while (attrs.hasMoreElements()) { String attrName = (String) attrs.nextElement(); result.put(attrName, request.getAttribute(attrName)); }//from w ww .j av a 2 s .c om return result; }
From source file:au.edu.anu.portal.portlets.basiclti.adapters.NoteflightAdapter.java
/** * Currently returns the map of params unchanged (except for adding the default params). * /*from ww w.j av a 2s .c o m*/ * <p> * Note this is currently equivalent to a standard Basic LTI launch. * This adapter has been added to cater for any custom behaviour that Noteflight may provide in the future. * * @param params map of launch data params * @return the map, unchanged */ @Override public Map<String, String> processLaunchData(Map<String, String> params) { log.debug("NoteflightAdapter.processLaunchData() called"); //add defaults params.putAll(super.getDefaultParameters()); return params; }
From source file:au.edu.anu.portal.portlets.basiclti.adapters.WikispacesAdapter.java
/** * Currently returns the map of params unchanged (except for adding the default params). * /*from w w w. jav a2s. c om*/ * <p> * Note this is currently equivalent to a standard Basic LTI launch. * This adapter has been added to cater for any custom behaviour that Wikispaces may provide in the future. * * @param params map of launch data params * @return the map, unchanged */ @Override public Map<String, String> processLaunchData(Map<String, String> params) { log.debug("WikispacesAdapter.processLaunchData() called"); //add defaults params.putAll(super.getDefaultParameters()); return params; }
From source file:com.dtstack.jlogstash.distributed.http.server.PostHandler.java
protected Map<String, Object> parseQuery(String query) throws IOException { Map<String, Object> parameters = Maps.newConcurrentMap(); if (StringUtils.isNotBlank(query)) { parameters.putAll(objectMapper.readValue(query.getBytes(), Map.class)); }//from ww w . j ava2 s.com return parameters; }