List of usage examples for com.mongodb MongoClientURI getPassword
@Nullable public char[] getPassword()
From source file:org.netbeans.modules.mongodb.native_tools.MongoTopExecAction.java
License:Open Source License
private void parseOptionsFromURI(MongoClientURI uri, Map<String, String> options) { if (uri.getUsername() != null && uri.getUsername().isEmpty() == false) { options.put(MongoDumpOptions.USERNAME, uri.getUsername()); }/*from w w w. ja v a 2 s. co m*/ if (uri.getPassword() != null && uri.getPassword().length > 0) { options.put(MongoDumpOptions.PASSWORD, new String(uri.getPassword())); } if (uri.getHosts() != null && uri.getHosts().isEmpty() == false) { final String hostWithPort = uri.getHosts().get(0); final Pattern p = Pattern.compile("(.*)(:(\\d+))?"); final Matcher m = p.matcher(hostWithPort); if (m.matches()) { final String host = m.group(1); final String port = m.group(3); if (host.isEmpty() == false) { options.put(MongoDumpOptions.HOST, host); if (port != null) { options.put(MongoDumpOptions.PORT, port); } } } } }
From source file:org.netbeans.modules.mongodb.ui.components.MongoURIEditorPanel.java
License:Open Source License
public void setMongoURI(MongoClientURI uri) { hostsListModel.clear();// w w w . j a va 2 s .c o m optionsListModel.clear(); for (String string : uri.getHosts()) { final String[] rawHost = string.split(":"); final String hostname = urlDecode(rawHost[0]); final Integer port = rawHost.length > 1 ? Integer.parseInt(rawHost[1]) : null; hostsListModel.addElement(new Host(hostname, port)); } usernameField.setText(uri.getUsername()); if (uri.getPassword() != null) { passwordField.setText(new String(uri.getPassword())); } databaseField.setText(uri.getDatabase()); final List<Option> options = decodeOptions(uri); optionsListModel.clear(); for (Option option : options) { optionsListModel.addElement(option); } updateURIField(); }
From source file:rapture.repo.integration.LocalTestSetup.java
License:Open Source License
public static void createUser() throws IOException, InterruptedException { String mongoHost = MultiValueConfigLoader.getConfig("MONGODB-integrationTest"); log.info("Host is " + mongoHost); if (mongoHost != null) { MongoClientURI uri = new MongoClientURI(mongoHost); List<String> hosts = uri.getHosts(); for (String host : hosts) { String[] cmdarray = createSetupCommand(host, uri.getDatabase(), uri.getUsername(), new String(uri.getPassword())); Process process = Runtime.getRuntime().exec(cmdarray); int retVal = process.waitFor(); log.info(String.format("retVal=%s", retVal)); log.info("output is " + IOUtils.toString(process.getInputStream())); if (retVal != 0) { log.info("error is " + IOUtils.toString(process.getErrorStream())); }/* ww w. j av a2 s .c om*/ } } else { log.error("mongo host is not defined!"); } }