List of usage examples for org.springframework.util Assert notEmpty
public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier)
From source file:org.apache.ambari.server.actionmanager.Stage.java
/** * Adds cancel command to stage for given cancelTargets collection of * task id's that has to be canceled in Agent layer. *//*ww w. j a v a2 s .c o m*/ public synchronized void addCancelRequestCommand(List<Long> cancelTargets, String clusterName, String hostName) { ExecutionCommandWrapper commandWrapper = addGenericExecutionCommand(clusterName, hostName, Role.AMBARI_SERVER_ACTION, RoleCommand.ABORT, null, false); ExecutionCommand cmd = commandWrapper.getExecutionCommand(); cmd.setCommandType(AgentCommandType.CANCEL_COMMAND); Assert.notEmpty(cancelTargets, "Provided targets task Id are empty."); Map<String, String> roleParams = new HashMap<String, String>(); roleParams.put("cancelTaskIdTargets", StringUtils.join(cancelTargets, ',')); cmd.setRoleParams(roleParams); }
From source file:org.apache.metron.pcapservice.PcapGetterHBaseImpl.java
public PcapsResponse getPcaps(List<String> keys) throws IOException { Assert.notEmpty(keys, "'keys' must not be null or empty"); return getPcaps(keys, null, -1, -1, ConfigurationUtil.isDefaultIncludeReverseTraffic(), false, ConfigurationUtil.getDefaultResultSize()); }
From source file:org.apache.metron.pcapservice.PcapGetterHBaseImpl.java
/** * Adds reverse keys to the list if the flag 'includeReverseTraffic' is set to * true; removes duplicates and sorts the list by ascending order;. * /* ww w . j ava2s.co m*/ * @param keys * input keys * @param includeReverseTraffic * flag whether or not to include reverse traffic * @return List<String> */ @VisibleForTesting List<String> sortKeysByAscOrder(List<String> keys, boolean includeReverseTraffic) { Assert.notEmpty(keys, "'keys' must not be null"); if (includeReverseTraffic) { keys.addAll(PcapHelper.reverseKey(keys)); } List<String> deDupKeys = removeDuplicateKeys(keys); Collections.sort(deDupKeys); return deDupKeys; }
From source file:org.apache.metron.pcapservice.PcapGetterHBaseImpl.java
/** * <p>/*from w w w . j a v a2 s . co m*/ * Returns the sublist starting from the element after the lastRowKey * to the last element in the list; if the 'lastRowKey' is not matched * the complete list will be returned. * </p> * * <pre> * Eg : * keys = [18800006-1800000b-06-0019-caac, 18800006-1800000b-06-0050-5af6, 18800006-1800000b-11-0035-3810] * lastRowKey = "18800006-1800000b-06-0019-caac-65140-40815" * and the response from this method [18800006-1800000b-06-0050-5af6, 18800006-1800000b-11-0035-3810] * </pre> * * @param keys * keys * @param lastRowKey * last row key of the previous partial response * @return List<String> */ @VisibleForTesting List<String> getUnprocessedSublistOfKeys(List<String> keys, String lastRowKey) { Assert.notEmpty(keys, "'keys' must not be null"); Assert.hasText(lastRowKey, "'lastRowKey' must not be null"); String partialKey = getTokens(lastRowKey, 5); int startIndex = 0; for (int i = 0; i < keys.size(); i++) { if (partialKey.equals(keys.get(i))) { startIndex = i + 1; break; } } List<String> unprocessedKeys = keys.subList(startIndex, keys.size()); return unprocessedKeys; }
From source file:org.apache.metron.pcapservice.PcapHelper.java
/** * Builds the reverseKeys to fetch the pcaps in the reverse traffic * (destination to source). If all keys in the input are not in the expected * format, it returns an empty list;//www . j a v a2s. c o m * * @param keys * indicates list of hbase rowKeys (partial or full) in the format * "srcAddr-dstAddr-protocol-srcPort-dstPort-fragment" * @return List<String> indicates the list of keys in the format * "dstAddr-srcAddr-protocol-dstPort-srcPort" */ public static List<String> reverseKey(List<String> keys) { Assert.notEmpty(keys, "'keys' must not be null or empty"); List<String> reverseKeys = new ArrayList<String>(); for (String key : keys) { if (key != null) { String reverseKey = reverseKey(key); if (StringUtils.isNotEmpty(reverseKey)) { reverseKeys.add(reverseKey); } } } return reverseKeys; }
From source file:org.apache.usergrid.corepersistence.CpEntityManager.java
@Override public Map<String, EntityRef> getAlias(EntityRef ownerRef, String collName, List<String> aliases) throws Exception { if (logger.isTraceEnabled()) { logger.trace("getAliases() for collection {} aliases {}", collName, aliases); }/*w w w . j a v a 2 s . c o m*/ Assert.notNull(ownerRef, "ownerRef is required"); Assert.notNull(collName, "collectionName is required"); Assert.notEmpty(aliases, "aliases are required"); String propertyName = Schema.getDefaultSchema().aliasProperty(collName); Map<String, EntityRef> results = new HashMap<>(); for (String alias : aliases) { Iterable<EntityRef> refs = getEntityRefsForUniqueProperty(collName, propertyName, alias); for (EntityRef ref : refs) { results.put(alias, ref); } } return results; }
From source file:org.apache.usergrid.persistence.cassandra.EntityManagerImpl.java
@Override @Metered(group = "core", name = "EntityManager_getAlias_multi") public Map<String, EntityRef> getAlias(UUID ownerId, String collectionName, List<String> aliases) throws Exception { Assert.notNull(ownerId, "ownerId is required"); Assert.notNull(collectionName, "collectionName is required"); Assert.notEmpty(aliases, "aliases are required"); String propertyName = Schema.getDefaultSchema().aliasProperty(collectionName); Map<String, EntityRef> results = new HashMap<String, EntityRef>(); for (String alias : aliases) { for (UUID id : getUUIDsForUniqueProperty(ownerId, collectionName, propertyName, alias)) { results.put(alias, new SimpleEntityRef(collectionName, id)); }// w w w . j a v a 2s.co m } return results; }
From source file:org.apereo.portal.layout.profile.ServerNameGuestChainingProfileMapper.java
@Override public void afterPropertiesSet() throws Exception { Assert.notEmpty(authorizedServerNames, "No authorized server name provided !"); }
From source file:org.cleverbus.core.common.asynch.notification.EmailServiceCamelSmtpImpl.java
@Override public void sendEmail(final Email email) { Assert.notNull(email, "email can not be null"); Assert.notEmpty(email.getRecipients(), "email must have at least one recipients"); Assert.hasText(email.getSubject(), "subject in email can not be empty"); Assert.hasText(email.getBody(), "body in email can not be empty"); producerTemplate.send("smtp://" + smtp, new Processor() { @Override/*from w w w. j a va 2 s .c o m*/ public void process(final Exchange exchange) throws Exception { Message in = exchange.getIn(); in.setHeader("To", StringUtils.join(email.getRecipients(), ",")); in.setHeader("From", StringUtils.isBlank(email.getFrom()) ? from : email.getFrom()); in.setHeader("Subject", email.getSubject()); in.setHeader("contentType", email.getContentType().getContentType()); in.setBody(email.getBody()); if (email.getAllAtachments() != null && !email.getAllAtachments().isEmpty()) { for (EmailAttachment attachment : email.getAllAtachments()) { in.addAttachment(attachment.getFileName(), new DataHandler(new ByteArrayDataSource(attachment.getContent(), "*/*"))); } } } }); }
From source file:org.cleverbus.core.common.dao.MessageDaoJpaImpl.java
@Override public int getCountProcessingMessagesForFunnel(Collection<String> funnelValues, int idleInterval, String funnelCompId) {/* w w w . ja v a2 s . c om*/ Assert.notEmpty(funnelValues, "funnelValues must not be empty"); Assert.hasText(funnelCompId, "funnelCompId must not be empty"); String jSql = "SELECT COUNT(m) " + "FROM " + Message.class.getName() + " m " + "INNER JOIN m.funnels f " + "WHERE (m.state = '" + MsgStateEnum.PROCESSING + "' " + " OR m.state = '" + MsgStateEnum.WAITING + "'" + " OR m.state = '" + MsgStateEnum.WAITING_FOR_RES + "')" + " AND m.startProcessTimestamp >= :startTime" + " AND m.funnelComponentId = '" + funnelCompId + "'" + " AND ("; for (String funnelValue : funnelValues) { jSql += "f.funnelValue = '" + funnelValue + "' OR "; } //remove last or jSql = StringUtils.substringBeforeLast(jSql, " OR "); jSql += ")"; TypedQuery<Number> q = em.createQuery(jSql, Number.class); q.setParameter("startTime", new Timestamp(DateUtils.addSeconds(new Date(), -idleInterval).getTime())); return q.getSingleResult().intValue(); }