List of usage examples for java.util Collections singletonList
public static <T> List<T> singletonList(T o)
From source file:ch.cyberduck.core.googledrive.DriveMoveFeature.java
@Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { try {/*w w w .j a v a2 s . co m*/ if (status.isExists()) { delete.delete(Collections.singletonList(renamed), connectionCallback, callback); } final String fileid = new DriveFileidProvider(session).getFileid(file, new DisabledListProgressListener()); if (!StringUtils.equals(file.getName(), renamed.getName())) { // Rename title final File properties = new File(); properties.setName(renamed.getName()); properties.setMimeType(status.getMime()); session.getClient().files().update(fileid, properties) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")) .execute(); } // Retrieve the existing parents to remove final StringBuilder previousParents = new StringBuilder(); final File reference = session.getClient().files().get(fileid).setFields("parents") .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")) .execute(); for (String parent : reference.getParents()) { previousParents.append(parent); previousParents.append(','); } // Move the file to the new folder session.getClient().files().update(fileid, null) .setAddParents(new DriveFileidProvider(session).getFileid(renamed.getParent(), new DisabledListProgressListener())) .setRemoveParents(previousParents.toString()).setFields("id, parents") .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")) .execute(); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(renamed.attributes()).withVersionId(fileid)); } catch (IOException e) { throw new DriveExceptionMappingService().map("Cannot rename {0}", e, file); } }
From source file:org.apache.marmotta.ldclient.provider.youtube.mapping.YoutubeUriMapper.java
/** * Take the selected value, process it according to the mapping definition, and create Sesame Values using the * factory passed as argument.//ww w . j av a 2s.co m * * * @param resourceUri * @param selectedValue * @param factory * @return */ @Override public List<Value> map(String resourceUri, String selectedValue, ValueFactory factory) { if (selectedValue.startsWith("http://gdata.youtube.com/feeds/api/videos") && selectedValue.indexOf('?') >= 0) { return Collections.singletonList( (Value) factory.createURI(selectedValue.substring(0, selectedValue.indexOf('?')))); } else if (selectedValue.startsWith("http://www.youtube.com/v/")) { String[] p_components = selectedValue.split("/"); String video_id = p_components[p_components.length - 1]; return Collections.singletonList( (Value) factory.createURI("http://gdata.youtube.com/feeds/api/videos/" + video_id)); } else if (selectedValue.startsWith("http://www.youtube.com/watch")) { try { URI uri = new URI(selectedValue); List<NameValuePair> params = URLEncodedUtils.parse(uri, "UTF-8"); String video_id = null; for (NameValuePair pair : params) { if ("v".equals(pair.getName())) { video_id = pair.getValue(); } } if (video_id != null) { return Collections.singletonList( (Value) factory.createURI("http://gdata.youtube.com/feeds/api/videos/" + video_id)); } } catch (URISyntaxException e) { return Collections.singletonList((Value) factory.createURI(selectedValue)); } } return Collections.singletonList((Value) factory.createURI(selectedValue)); }
From source file:com.epam.training.storefront.controllers.pages.AbstractLoginPageController.java
protected String getDefaultLoginPage(final boolean loginError, final HttpSession session, final Model model) throws CMSItemNotFoundException { final LoginForm loginForm = new LoginForm(); model.addAttribute(loginForm);//from w w w .j av a2 s.c o m model.addAttribute(new RegisterForm()); final String username = (String) session.getAttribute(SPRING_SECURITY_LAST_USERNAME); if (username != null) { session.removeAttribute(SPRING_SECURITY_LAST_USERNAME); } loginForm.setJ_username(username); storeCmsPageInModel(model, getCmsPage()); setUpMetaDataForContentPage(model, (ContentPageModel) getCmsPage()); model.addAttribute("metaRobots", "index,no-follow"); final Breadcrumb loginBreadcrumbEntry = new Breadcrumb("#", getMessageSource().getMessage("header.link.login", null, getI18nService().getCurrentLocale()), null); model.addAttribute("breadcrumbs", Collections.singletonList(loginBreadcrumbEntry)); if (loginError) { GlobalMessages.addErrorMessage(model, "login.error.account.not.found.title"); } return getView(); }
From source file:com.mycompany.securitylogin.model.User.java
@Override public Collection<? extends GrantedAuthority> getAuthorities() { return Collections.singletonList(new SimpleGrantedAuthority("ADMIN")); }
From source file:pl.edu.agh.iosr.lsf.RootController.java
@RequestMapping(value = "/query", method = RequestMethod.POST) public List<String[]> executeQuery(@RequestPart(value = "query") String sql) { try {// www . ja v a 2 s . com return dh.select(sql); } catch (SQLException e) { return Collections.singletonList(new String[] { e.getMessage() }); } }
From source file:com.haulmont.yarg.formatters.impl.doc.connector.LinuxProcessManager.java
@Override public List<Long> findPid(String host, int port) { try {//from w w w . j av a 2 s. com String regex = Pattern.quote(host) + ".*" + port; Pattern commandPattern = Pattern.compile(regex); List<String> lines = execute(psCommand()); List<Long> result = new ArrayList<Long>(); for (String line : lines) { Matcher lineMatcher = PS_OUTPUT_LINE.matcher(line); if (lineMatcher.matches()) { String command = lineMatcher.group(2); Matcher commandMatcher = commandPattern.matcher(command); if (commandMatcher.find()) { result.add(Long.parseLong(lineMatcher.group(1))); } } } return result; } catch (IOException e) { log.error("An error occured while searching for soffice PID in linux system", e); } return Collections.singletonList(PID_UNKNOWN); }
From source file:com.hortonworks.streamline.streams.runtime.rule.sql.SqlBasicExprScriptTest.java
@Test public void testBasicNoMatch() throws Exception { Condition condition = new Condition(); Expression x = new FieldExpression(Schema.Field.of("x", Schema.Type.INTEGER)); condition.setExpression(new BinaryExpression(Operator.NOT_EQUAL, x, new Literal("100"))); sqlScript = new SqlScript(new StormSqlExpression(condition), new SqlEngine(), new SqlScript.CorrelatedValuesToStreamlineEventConverter(Collections.singletonList("x"))); Map<String, Object> kv = new HashMap<>(); kv.put("x", 100); StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(kv).dataSourceId("1").build(); Collection<StreamlineEvent> result = sqlScript.evaluate(event); Assert.assertTrue(result.isEmpty()); }
From source file:com.hortonworks.streamline.streams.cluster.register.impl.KafkaServiceRegistrar.java
@Override protected List<Component> createComponents(Config config, Map<String, String> flattenConfigMap) { Component kafkaBroker = createKafkaBrokerComponent(config, flattenConfigMap); return Collections.singletonList(kafkaBroker); }
From source file:io.seventyone.mongoutils.MongoServiceImplementation.java
public MongoServiceImplementation(String host, int port, String dbName, String user, String password) { ServerAddress serverAddress = new ServerAddress(host, port); if (StringUtils.isBlank(user)) { this.mongoClient = new MongoClient(serverAddress); } else {/*from w w w . j a v a 2 s . c o m*/ MongoCredential credential = MongoCredential.createCredential(user, dbName, password.toCharArray()); this.mongoClient = new MongoClient(serverAddress, Collections.singletonList(credential)); } this.db = this.mongoClient.getDatabase(dbName); }
From source file:org.apigw.authserver.svc.encrypted.EncryptedAuthorizationCodeServices.java
@Override public String createAuthorizationCode(AuthorizationRequestHolder authentication) { log.debug("createAuthorizationCode"); UserDetails userDetails = (UserDetails) authentication.getUserAuthentication().getPrincipal(); String encryptedUsername = encrypter.encrypt(userDetails.getUsername()); User secureUser = new User(encryptedUsername, "", Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"))); SimpleAuthentication auth = new SimpleAuthentication(secureUser); AuthorizationRequestHolder secureAuth = new AuthorizationRequestHolder( authentication.getAuthenticationRequest(), auth); return getAuthorizationCodeServices().createAuthorizationCode(secureAuth); }