Java Code Examples for org.apache.commons.lang3.StringUtils#isAllEmpty()
The following examples show how to use
org.apache.commons.lang3.StringUtils#isAllEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmailSmtpConnector.java From mxisd with GNU Affero General Public License v3.0 | 6 votes |
public EmailSmtpConnector(EmailSmtpConfig cfg) { this.cfg = cfg.build(); Properties sCfg = new Properties(); sCfg.setProperty("mail.smtp.host", cfg.getHost()); sCfg.setProperty("mail.smtp.port", Integer.toString(cfg.getPort())); // This seems very fiddly as we need to call different connect() methods depending // If there is authentication or not. We set those for the sake of completeness and // Backward compatibility. See previously opened issues about Email and SMTP. if (StringUtils.isAllEmpty(cfg.getLogin(), cfg.getPassword())) { sCfg.setProperty("mail.smtp.auth", "false"); } else { sCfg.setProperty("mail.smtp.auth", "true"); } if (cfg.getTls() == 3) { sCfg.setProperty("mail.smtp.ssl.enable", "true"); } session = Session.getInstance(sCfg); }
Example 2
Source File: BrowserRunnerHelper.java From neodymium-library with MIT License | 5 votes |
public static Proxy createProxyCapabilities() { final String proxyHost = Neodymium.configuration().getProxyHost() + ":" + Neodymium.configuration().getProxyPort(); final Proxy webdriverProxy = new Proxy(); webdriverProxy.setHttpProxy(proxyHost); webdriverProxy.setSslProxy(proxyHost); webdriverProxy.setFtpProxy(proxyHost); if (!StringUtils.isAllEmpty(Neodymium.configuration().getProxySocketUsername(), Neodymium.configuration().getProxySocketPassword()) || Neodymium.configuration().getProxySocketVersion() != null) { webdriverProxy.setSocksProxy(proxyHost); if (StringUtils.isNoneEmpty(Neodymium.configuration().getProxySocketUsername(), Neodymium.configuration().getProxySocketPassword())) { webdriverProxy.setSocksUsername(Neodymium.configuration().getProxySocketUsername()); webdriverProxy.setSocksPassword(Neodymium.configuration().getProxySocketPassword()); } if (Neodymium.configuration().getProxySocketVersion() != null) { webdriverProxy.setSocksVersion(4); } } webdriverProxy.setNoProxy(Neodymium.configuration().getProxyBypass()); return webdriverProxy; }
Example 3
Source File: API.java From carbon-apimgt with Apache License 2.0 | 5 votes |
public String getEndpointConfig() { // This is to support new Endpoint object if ((endpointConfig == null || StringUtils.isAllEmpty(endpointConfig) && endpoints.size() > 0)) { return getEndpointConfigString(endpoints); } return endpointConfig; }
Example 4
Source File: ApiFriendService.java From wind-im with Apache License 2.0 | 4 votes |
/** * 查询好友的资料信息,点击好友头像查看使用 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; try { ApiFriendProfileProto.ApiFriendProfileRequest request = ApiFriendProfileProto.ApiFriendProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String globalOrSiteFriendId = request.getSiteUserId();// 等待查询的站点用户ID || globalUserId String userIdPubk = request.getUserIdPubk(); // 等待查询的用户公钥,优先级高 LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAllEmpty(userIdPubk, globalOrSiteFriendId)) { errCode = ErrorCode2.ERROR_PARAMETER; return commandResponse.setErrCode2(errCode); } // 1.如果是siteUserId UserFriendBean userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, globalOrSiteFriendId); // 2.如果不是则认为是globalUserId if (null == userBean || StringUtils.isNotEmpty(userBean.getSiteUserId())) { String siteFriendId = UserProfileDao.getInstance().getSiteUserIdByGlobalUserId(globalOrSiteFriendId); if (StringUtils.isNotEmpty(siteFriendId)) { userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, siteFriendId); } } if (userBean != null && StringUtils.isNotBlank(userBean.getSiteUserId())) { UserProto.UserProfile.Builder friendProfileBuilder = UserProto.UserProfile.newBuilder(); friendProfileBuilder.setSiteUserId(userBean.getSiteUserId()); friendProfileBuilder.setUserIdPubk(userBean.getUserIdPubk()); if (StringUtils.isNotEmpty(userBean.getAliasName())) { friendProfileBuilder.setUserName(userBean.getAliasName()); if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setNickName(userBean.getUserName()); } } else { if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setUserName(userBean.getUserName()); friendProfileBuilder.setNickName(userBean.getUserName()); } } if (StringUtils.isNotEmpty(userBean.getSiteLoginId())) { friendProfileBuilder.setSiteLoginId(userBean.getSiteLoginId()); } if (StringUtils.isNotEmpty(userBean.getUserPhoto())) { friendProfileBuilder.setUserPhoto(userBean.getUserPhoto()); } friendProfileBuilder.setUserStatusValue(userBean.getUserStatus()); UserProto.UserProfile friendProfile = friendProfileBuilder.build(); // 查关系 UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, userBean.getSiteUserId()); ApiFriendProfileProto.ApiFriendProfileResponse response = ApiFriendProfileProto.ApiFriendProfileResponse .newBuilder().setProfile(friendProfile).setRelation(userRelation) .setUserIdPubk(userBean.getUserIdPubk()).build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } } catch (Exception e) { errCode = ErrorCode2.ERROR_SYSTEMERROR; LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode2(errCode); }
Example 5
Source File: ApiFriendService.java From openzaly with Apache License 2.0 | 4 votes |
/** * 查询好友的资料信息,点击好友头像查看使用 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; try { ApiFriendProfileProto.ApiFriendProfileRequest request = ApiFriendProfileProto.ApiFriendProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String globalOrSiteFriendId = request.getSiteUserId();// 等待查询的站点用户ID || globalUserId String userIdPubk = request.getUserIdPubk(); // 等待查询的用户公钥,优先级高 LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAllEmpty(userIdPubk, globalOrSiteFriendId)) { errCode = ErrorCode2.ERROR_PARAMETER; return commandResponse.setErrCode2(errCode); } // 1.如果是siteUserId UserFriendBean userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, globalOrSiteFriendId); // 2.如果不是则认为是globalUserId if (null == userBean || StringUtils.isNotEmpty(userBean.getSiteUserId())) { String siteFriendId = UserProfileDao.getInstance().getSiteUserIdByGlobalUserId(globalOrSiteFriendId); if (StringUtils.isNotEmpty(siteFriendId)) { userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, siteFriendId); } } if (userBean != null && StringUtils.isNotBlank(userBean.getSiteUserId())) { UserProto.UserProfile.Builder friendProfileBuilder = UserProto.UserProfile.newBuilder(); friendProfileBuilder.setSiteUserId(userBean.getSiteUserId()); friendProfileBuilder.setUserIdPubk(userBean.getUserIdPubk()); if (StringUtils.isNotEmpty(userBean.getAliasName())) { friendProfileBuilder.setUserName(userBean.getAliasName()); if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setNickName(userBean.getUserName()); } } else { if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setUserName(userBean.getUserName()); friendProfileBuilder.setNickName(userBean.getUserName()); } } if (StringUtils.isNotEmpty(userBean.getSiteLoginId())) { friendProfileBuilder.setSiteLoginId(userBean.getSiteLoginId()); } if (StringUtils.isNotEmpty(userBean.getUserPhoto())) { friendProfileBuilder.setUserPhoto(userBean.getUserPhoto()); } friendProfileBuilder.setUserStatusValue(userBean.getUserStatus()); UserProto.UserProfile friendProfile = friendProfileBuilder.build(); // 查关系 UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, userBean.getSiteUserId()); ApiFriendProfileProto.ApiFriendProfileResponse response = ApiFriendProfileProto.ApiFriendProfileResponse .newBuilder().setProfile(friendProfile).setRelation(userRelation) .setUserIdPubk(userBean.getUserIdPubk()).build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } } catch (Exception e) { errCode = ErrorCode2.ERROR_SYSTEMERROR; LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode2(errCode); }
Example 6
Source File: ApiFriendService.java From openzaly with Apache License 2.0 | 4 votes |
/** * 查询好友的资料信息,点击好友头像查看使用 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; try { ApiFriendProfileProto.ApiFriendProfileRequest request = ApiFriendProfileProto.ApiFriendProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String globalOrSiteFriendId = request.getSiteUserId();// 等待查询的站点用户ID || globalUserId String userIdPubk = request.getUserIdPubk(); // 等待查询的用户公钥,优先级高 LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAllEmpty(userIdPubk, globalOrSiteFriendId)) { errCode = ErrorCode2.ERROR_PARAMETER; return commandResponse.setErrCode2(errCode); } // 1.如果是siteUserId UserFriendBean userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, globalOrSiteFriendId); // 2.如果不是则认为是globalUserId if (null == userBean || StringUtils.isNotEmpty(userBean.getSiteUserId())) { String siteFriendId = UserProfileDao.getInstance().getSiteUserIdByGlobalUserId(globalOrSiteFriendId); if (StringUtils.isNotEmpty(siteFriendId)) { userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, siteFriendId); } } if (userBean != null && StringUtils.isNotBlank(userBean.getSiteUserId())) { UserProto.UserProfile.Builder friendProfileBuilder = UserProto.UserProfile.newBuilder(); friendProfileBuilder.setSiteUserId(userBean.getSiteUserId()); friendProfileBuilder.setUserIdPubk(userBean.getUserIdPubk()); if (StringUtils.isNotEmpty(userBean.getAliasName())) { friendProfileBuilder.setUserName(userBean.getAliasName()); if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setNickName(userBean.getUserName()); } } else { if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setUserName(userBean.getUserName()); friendProfileBuilder.setNickName(userBean.getUserName()); } } if (StringUtils.isNotEmpty(userBean.getSiteLoginId())) { friendProfileBuilder.setSiteLoginId(userBean.getSiteLoginId()); } if (StringUtils.isNotEmpty(userBean.getUserPhoto())) { friendProfileBuilder.setUserPhoto(userBean.getUserPhoto()); } friendProfileBuilder.setUserStatusValue(userBean.getUserStatus()); UserProto.UserProfile friendProfile = friendProfileBuilder.build(); // 查关系 UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, userBean.getSiteUserId()); ApiFriendProfileProto.ApiFriendProfileResponse response = ApiFriendProfileProto.ApiFriendProfileResponse .newBuilder().setProfile(friendProfile).setRelation(userRelation) .setUserIdPubk(userBean.getUserIdPubk()).build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } } catch (Exception e) { errCode = ErrorCode2.ERROR_SYSTEMERROR; LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode2(errCode); }
Example 7
Source File: EmailSmtpConnector.java From mxisd with GNU Affero General Public License v3.0 | 4 votes |
@Override public void send(String senderAddress, String senderName, String recipient, String content) { if (StringUtils.isBlank(senderAddress)) { throw new FeatureNotAvailable("3PID Email identity: sender address is empty - " + "You must set a value for notifications to work"); } if (StringUtils.isBlank(content)) { throw new InternalServerError("Notification content is empty"); } try { InternetAddress sender = new InternetAddress(senderAddress, senderName); MimeMessage msg = new MimeMessage(session, IOUtils.toInputStream(content, StandardCharsets.UTF_8)); // We must encode our headers ourselves as we have no guarantee that they were in the provided data. // This is required to support UTF-8 characters from user display names or room names in the subject header per example Enumeration<Header> headers = msg.getAllHeaders(); while (headers.hasMoreElements()) { Header header = headers.nextElement(); msg.setHeader(header.getName(), MimeUtility.encodeText(header.getValue())); } msg.setHeader("X-Mailer", MimeUtility.encodeText(Mxisd.Agent)); msg.setSentDate(new Date()); msg.setFrom(sender); msg.setRecipients(Message.RecipientType.TO, recipient); msg.saveChanges(); log.info("Sending invite to {} via SMTP using {}:{}", recipient, cfg.getHost(), cfg.getPort()); SMTPTransport transport = (SMTPTransport) session.getTransport("smtp"); if (cfg.getTls() < 3) { transport.setStartTLS(cfg.getTls() > 0); transport.setRequireStartTLS(cfg.getTls() > 1); } log.info("Connecting to {}:{}", cfg.getHost(), cfg.getPort()); if (StringUtils.isAllEmpty(cfg.getLogin(), cfg.getPassword())) { log.info("Not using SMTP authentication"); transport.connect(); } else { log.info("Using SMTP authentication"); transport.connect(cfg.getLogin(), cfg.getPassword()); } try { transport.sendMessage(msg, InternetAddress.parse(recipient)); log.info("Invite to {} was sent", recipient); } finally { transport.close(); } } catch (UnsupportedEncodingException | MessagingException e) { throw new RuntimeException("Unable to send e-mail invite to " + recipient, e); } }
Example 8
Source File: ProxyConfigAuthValidator.java From cloudbreak with Apache License 2.0 | 4 votes |
@Override public boolean isValid(ProxyRequest proxyRequest, ConstraintValidatorContext constraintValidatorContext) { String user = proxyRequest.getUserName(); String password = proxyRequest.getPassword(); return StringUtils.isAllEmpty(user, password) || StringUtils.isNoneBlank(user, password); }