List of usage examples for java.util Map containsValue
boolean containsValue(Object value);
From source file:org.craftercms.social.services.system.impl.SocialContextServiceImpl.java
@Override @HasPermission(type = SocialPermission.class, action = SecurityActionNames.SYSTEM_REMOVE_PROFILE_CONTEXT) public Profile removeProfileFromContext(final String contextId, final String profileId) throws SocialException { try {/*w ww .ja v a2s .c om*/ Profile p = profileService.getProfile(profileId, SocialSecurityUtils.SOCIAL_CONTEXTS_ATTRIBUTE); if (p == null) { throw new ProfileConfigurationException("Given profile \"" + profileId + "\" does not exist"); } SocialContext ctx = socialContextRepository.findById(contextId); if (ctx == null) { throw new ProfileConfigurationException("Given context \"" + contextId + "\" does not exist"); } List<Map<String, Object>> updatedList = new ArrayList<>(); final HashMap<String, Object> attributesToUpdate = new HashMap<>(); List<Map<String, Object>> socialContexts = (List<Map<String, Object>>) p .getAttribute(SocialSecurityUtils.SOCIAL_CONTEXTS_ATTRIBUTE); if (socialContexts == null) { return p; } for (Map<String, Object> socialContext : socialContexts) { if (!socialContext.containsValue(ctx.getId())) { updatedList.add(socialContext); } } attributesToUpdate.put(SocialSecurityUtils.SOCIAL_CONTEXTS_ATTRIBUTE, updatedList); return profileService.updateAttributes(profileId, attributesToUpdate, FIRST_NAME_ATTRIBUTE, LAST_NAME_ATTRIBUTE, DISPLAY_NAME_ATTRIBUTE, AVATAR_LINK_ATTRIBUTE, SocialSecurityUtils.SOCIAL_CONTEXTS_ATTRIBUTE); } catch (ProfileException ex) { log.error("Unable to find profile with given id " + profileId, ex); throw new SocialException("Unable to find profile ", ex); } catch (MongoDataException e) { log.error("Unable to look for SocialContext", e); throw new SocialException("Unable to find Context by id", e); } }
From source file:com.robonobo.eon.ConnectionHolder.java
synchronized boolean haveConnection(EONConnection conn, int localEonPort) { Integer eonPort = new Integer(localEonPort); if (defaultConns.containsValue(conn)) return true; if (specificConns.containsKey(eonPort)) { Map<EonSocketAddress, EONConnection> portMap = specificConns.get(eonPort); if (portMap.containsValue(conn)) return true; }//from w ww .java 2s . c om return false; }
From source file:org.sonatype.nexus.configuration.application.DefaultNexusConfigurationTest.java
@Test public void testGetAndReadConfigurationFiles() throws Exception { File testConfFile = new File(getConfHomeDir(), "test.xml"); FileUtils.write(testConfFile, "test"); Map<String, String> confFileNames = nexusConfiguration.getConfigurationFiles(); assertTrue(confFileNames.size() > 1); assertTrue(confFileNames.containsValue("nexus.xml")); assertTrue(confFileNames.containsValue("test.xml")); for (Map.Entry<String, String> entry : confFileNames.entrySet()) { if (entry.getValue().equals("test.xml")) { contentEquals(new ByteArrayInputStream("test".getBytes()), nexusConfiguration.getConfigurationAsStreamByKey(entry.getKey()).getInputStream()); } else if (entry.getValue().equals("nexus.xml")) { contentEquals(new FileInputStream(new File(getNexusConfiguration())), nexusConfiguration.getConfigurationAsStreamByKey(entry.getKey()).getInputStream()); }/* w ww . jav a 2s . com*/ } FileUtils.forceDelete(testConfFile); }
From source file:coral.model.ExpData.java
@Override public boolean containsValue(Object value) { boolean result = false; for (Map<String, String> m : refMap.values()) { result = result || m.containsValue(value); }//from ww w . j ava2 s . c o m return result; }
From source file:org.apache.hadoop.mapred.TestTaskEnvironment.java
@Test public void testTaskEnv() throws Throwable { ttConf.set("mapreduce.admin.user.shell", "/bin/testshell"); ttConf.set("mapreduce.admin.user.env", "key1=value1,key2=value2"); ttConf.set("mapred.child.env", "ROOT=$HOME"); final Map<String, String> env = new HashMap<String, String>(); String user = "test"; JobConf taskConf = new JobConf(ttConf); TaskAttemptID attemptID = new TaskAttemptID("test", 0, true, 0, 0); Task task = new MapTask(null, attemptID, 0, null, MAP_SLOTS); task.setConf(taskConf);//from ww w. j a va 2 s. co m TaskInProgress tip = tt.new TaskInProgress(task, taskConf); RunningJob rjob = new RunningJob(attemptID.getJobID()); TaskController taskController = new DefaultTaskController(); taskController.setConf(ttConf); rjob.distCacheMgr = new TrackerDistributedCacheManager(ttConf, taskController) .newTaskDistributedCacheManager(attemptID.getJobID(), taskConf); final TaskRunner taskRunner = task.createRunner(tt, tip, rjob); String errorInfo = "Child error"; String mapredChildEnv = taskRunner.getChildEnv(taskConf); taskRunner.updateUserLoginEnv(errorInfo, user, taskConf, env); taskRunner.setEnvFromInputString(errorInfo, env, mapredChildEnv); final Vector<String> vargs = new Vector<String>(1); File pidFile = new File(TEST_DIR, "pid"); vargs.add(writeScript("ENV", "/bin/env ", pidFile).getAbsolutePath()); final File workDir = new File(TEST_DIR, "work"); workDir.mkdir(); final File stdout = new File(TEST_DIR, "stdout"); final File stderr = new File(TEST_DIR, "stderr"); Map<String, String> jvmenvmap = env; String javaOpts = taskRunner.getChildJavaOpts(ttConf, JobConf.MAPRED_MAP_TASK_JAVA_OPTS); assertTrue(jvmenvmap.containsKey("SHELL")); assertTrue(jvmenvmap.containsValue("/bin/testshell")); assertTrue(jvmenvmap.containsKey("key2")); assertTrue(jvmenvmap.containsValue("value2")); assertTrue(javaOpts, javaOpts.contains("Xmx")); assertTrue(javaOpts, javaOpts.contains("IPv4")); String root = jvmenvmap.get("ROOT"); assertTrue(root, root.contentEquals(System.getenv("HOME"))); }
From source file:org.zanata.adapter.glossary.GlossaryCSVReader.java
/** * Parser reads from all from first row and exclude column from description * map. Format of CVS: {source locale},{locale},{locale}...,pos,description *//* w w w . j a v a 2 s . c om*/ private Map<Integer, LocaleId> setupLocalesMap(List<CSVRecord> records, Map<String, Integer> descriptionMap) { Map<Integer, LocaleId> localeColMap = new HashMap<Integer, LocaleId>(); CSVRecord headerRow = records.get(0); for (int row = 0; row <= headerRow.size() && !descriptionMap.containsValue(row); row++) { LocaleId locale = new LocaleId(StringUtils.trim(headerRow.get(row))); localeColMap.put(row, locale); } return localeColMap; }
From source file:org.opencastproject.kernel.security.persistence.OrganizationPersistenceTest.java
@Test public void testAdding() throws Exception { Map<String, String> orgProperties = new HashMap<String, String>(); orgProperties.put("test", "one"); JpaOrganization org = new JpaOrganization("newOrg", "test organization", "test.org", 8080, "ROLE_TEST_ADMIN", "ROLE_TEST_ANONYMOUS", orgProperties); organizationDatabase.storeOrganization(org); Assert.assertTrue(organizationDatabase.containsOrganization("newOrg")); Organization orgById = organizationDatabase.getOrganization("newOrg"); Organization orgByHost = organizationDatabase.getOrganizationByHost("test.org", 8080); Assert.assertEquals(orgById, orgByHost); Assert.assertEquals("newOrg", orgById.getId()); Assert.assertEquals("test organization", orgById.getName()); Assert.assertEquals("ROLE_TEST_ADMIN", orgById.getAdminRole()); Assert.assertEquals("ROLE_TEST_ANONYMOUS", orgById.getAnonymousRole()); Map<String, Integer> servers = orgById.getServers(); Assert.assertEquals(1, servers.size()); Assert.assertTrue(servers.containsKey("test.org")); Assert.assertTrue(servers.containsValue(8080)); Map<String, String> properties = orgById.getProperties(); Assert.assertEquals(1, properties.size()); Assert.assertTrue(properties.containsKey("test")); Assert.assertTrue(properties.containsValue("one")); }
From source file:org.kalypso.model.wspm.pdb.wspm.CheckoutDataMapping.java
private void removeFromMapping(final Map<?, ?> mapping, final Feature element) { if (!mapping.containsValue(element)) return;//from w ww. ja v a 2s . c om for (final Entry<?, ?> entry : mapping.entrySet()) { if (element.equals(entry.getValue())) entry.setValue(null); } }
From source file:org.apereo.services.persondir.support.jdbc.MultiRowJdbcPersonAttributeDao.java
/** * The {@link Map} of columns from a name column to value columns. Keys are Strings, * Values are Strings or {@link java.util.List} of Strings. * * @param nameValueColumnMap The Map of name column to value column(s). *//*from w w w . j ava 2 s .co m*/ public void setNameValueColumnMappings(final Map<String, ?> nameValueColumnMap) { if (nameValueColumnMap == null) { this.nameValueColumnMappings = null; } else { final Map<String, Set<String>> mappings = MultivaluedPersonAttributeUtils .parseAttributeToAttributeMapping(nameValueColumnMap); if (mappings.containsValue(null)) { throw new IllegalArgumentException("nameValueColumnMap may not have null values"); } this.nameValueColumnMappings = mappings; } }
From source file:org.apigw.authserver.web.controller.CertifiedClientsController.java
@RequestMapping(value = "/oauth/clients", method = RequestMethod.GET) public String listClients(Model model) { log.debug("listClients"); Map<String, CertifiedClient> allCertifiedClients = new HashMap<String, CertifiedClient>(); allCertifiedClients.putAll(findAllCertifiedClients()); List<Map<String, Object>> availableClients = findAvailableClients(allCertifiedClients); sort(availableClients, createClientComparator()); List<CertifiedClientDetails> certifiedClientsWithUsersWithConfirmedAccess = createCollectionOfWhichCertifiedClientsHasUsersWithConfirmedAccess(); //Remove clients from available client as a client can not show up as installed client and an available client List<Map<String, Object>> copyOfAvailableClients = new ArrayList<Map<String, Object>>(); //To avoid ConcurrentModificationException copyOfAvailableClients.addAll(availableClients); for (CertifiedClientDetails certifiedClientDetails : certifiedClientsWithUsersWithConfirmedAccess) { for (Map<String, Object> availableClient : copyOfAvailableClients) { if (availableClient.containsValue(certifiedClientDetails.getClientId())) { availableClients.remove(availableClient); }//from w w w. j av a 2s .c om } } model.addAttribute("certifiedClients", certifiedClientsWithUsersWithConfirmedAccess); model.addAttribute("availableClients", availableClients); log.debug("certifiedClients: " + certifiedClientsWithUsersWithConfirmedAccess); log.debug("Available clients: " + availableClients); log.debug("returning from listClients"); return ".listClients"; }