use of java.util.ArrayList in project camel by apache.
the class BonitaAuthFilter method filter.
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
if (requestContext.getCookies().get("JSESSIONID") == null) {
String username = bonitaApiConfig.getUsername();
String password = bonitaApiConfig.getPassword();
String bonitaApiToken = null;
if (ObjectHelper.isEmpty(username)) {
throw new IllegalArgumentException("Username provided is null or empty.");
}
if (ObjectHelper.isEmpty(password)) {
throw new IllegalArgumentException("Password provided is null or empty.");
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
Client client = clientBuilder.build();
WebTarget webTarget = client.target(bonitaApiConfig.getBaseBonitaURI()).path("loginservice");
MultivaluedMap<String, String> form = new MultivaluedHashMap<String, String>();
form.add("username", username);
form.add("password", password);
form.add("redirect", "false");
Response response = webTarget.request().accept(MediaType.APPLICATION_FORM_URLENCODED).post(Entity.form(form));
Map<String, NewCookie> cr = response.getCookies();
ArrayList<Object> cookies = new ArrayList<>();
for (NewCookie cookie : cr.values()) {
if ("X-Bonita-API-Token".equals(cookie.getName())) {
bonitaApiToken = cookie.getValue();
requestContext.getHeaders().add("X-Bonita-API-Token", bonitaApiToken);
}
cookies.add(cookie.toCookie());
}
requestContext.getHeaders().put("Cookie", cookies);
}
}
use of java.util.ArrayList in project camel by apache.
the class BoxEventLogsManager method getEnterpriseEvents.
/**
* Create an event stream with optional starting initial position and add
* listener that will be notified when an event is received.
*
* @param position
* - the starting position of the event stream. May be
* <code>null</code> in which case all events within bounds
* returned.
* @param after
* - the lower bound on the timestamp of the events returned.
* @param after
* - the upper bound on the timestamp of the events returned.
* @param types
* - an optional list of event types to filter by.
*
* @return A list of all the events that met the given criteria.
*/
public List<BoxEvent> getEnterpriseEvents(String position, Date after, Date before, BoxEvent.Type... types) {
try {
LOG.debug("Getting all enterprise events occuring between " + (after == null ? after : SimpleDateFormat.getDateTimeInstance().format(after)) + " and " + (before == null ? before : SimpleDateFormat.getDateTimeInstance().format(before)) + (position == null ? position : (" starting at " + position)));
if (after == null) {
throw new IllegalArgumentException("Parameter 'after' can not be null");
}
if (before == null) {
throw new IllegalArgumentException("Parameter 'before' can not be null");
}
if (types == null) {
types = new BoxEvent.Type[0];
}
EventLog eventLog = EventLog.getEnterpriseEvents(boxConnection, position, after, before, types);
List<BoxEvent> results = new ArrayList<BoxEvent>();
for (BoxEvent event : eventLog) {
results.add(event);
}
return results;
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
use of java.util.ArrayList in project camel by apache.
the class ValueBuilder method in.
public Predicate in(Object... values) {
List<Predicate> predicates = new ArrayList<Predicate>();
for (Object value : values) {
Expression right = asExpression(value);
right = ExpressionBuilder.convertToExpression(right, expression);
Predicate predicate = onNewPredicate(PredicateBuilder.isEqualTo(expression, right));
predicates.add(predicate);
}
return in(predicates.toArray(new Predicate[predicates.size()]));
}
use of java.util.ArrayList in project camel by apache.
the class MethodInfo method findOneWayAnnotation.
/**
* Finds the oneway annotation in priority order; look for method level annotations first, then the class level annotations,
* then super class annotations then interface annotations
*
* @param method the method on which to search
* @return the first matching annotation or none if it is not available
*/
protected Pattern findOneWayAnnotation(Method method) {
Pattern answer = getPatternAnnotation(method);
if (answer == null) {
Class<?> type = method.getDeclaringClass();
// create the search order of types to scan
List<Class<?>> typesToSearch = new ArrayList<Class<?>>();
addTypeAndSuperTypes(type, typesToSearch);
Class<?>[] interfaces = type.getInterfaces();
for (Class<?> anInterface : interfaces) {
addTypeAndSuperTypes(anInterface, typesToSearch);
}
// now let's scan for a type which the current declared class overloads
answer = findOneWayAnnotationOnMethod(typesToSearch, method);
if (answer == null) {
answer = findOneWayAnnotation(typesToSearch);
}
}
return answer;
}
use of java.util.ArrayList in project camel by apache.
the class DefaultPackageScanClassResolver method doLoadJarClassEntries.
/**
* Loads all the class entries from the JAR.
*
* @param stream the inputstream of the jar file to be examined for classes
* @param urlPath the url of the jar file to be examined for classes
* @return all the .class entries from the JAR
*/
protected List<String> doLoadJarClassEntries(InputStream stream, String urlPath) {
List<String> entries = new ArrayList<String>();
JarInputStream jarStream = null;
try {
jarStream = new JarInputStream(stream);
JarEntry entry;
while ((entry = jarStream.getNextJarEntry()) != null) {
String name = entry.getName();
if (name != null) {
name = name.trim();
if (!entry.isDirectory() && name.endsWith(".class")) {
entries.add(name);
}
}
}
} catch (IOException ioe) {
log.warn("Cannot search jar file '" + urlPath + " due to an IOException: " + ioe.getMessage(), ioe);
} finally {
IOHelper.close(jarStream, urlPath, log);
}
return entries;
}
Aggregations