Search in sources :

Example 51 with ArrayList

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);
    }
}
Also used : ArrayList(java.util.ArrayList) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) Response(javax.ws.rs.core.Response) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) ClientBuilder(javax.ws.rs.client.ClientBuilder) NewCookie(javax.ws.rs.core.NewCookie)

Example 52 with ArrayList

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);
    }
}
Also used : BoxEvent(com.box.sdk.BoxEvent) EventLog(com.box.sdk.EventLog) ArrayList(java.util.ArrayList) BoxAPIException(com.box.sdk.BoxAPIException)

Example 53 with ArrayList

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()]));
}
Also used : Expression(org.apache.camel.Expression) ArrayList(java.util.ArrayList) Predicate(org.apache.camel.Predicate)

Example 54 with ArrayList

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;
}
Also used : ExchangePattern(org.apache.camel.ExchangePattern) Pattern(org.apache.camel.Pattern) ArrayList(java.util.ArrayList)

Example 55 with ArrayList

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;
}
Also used : JarInputStream(java.util.jar.JarInputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) JarEntry(java.util.jar.JarEntry)

Aggregations

ArrayList (java.util.ArrayList)55702 Test (org.junit.Test)8169 List (java.util.List)6815 HashMap (java.util.HashMap)5856 IOException (java.io.IOException)3899 Map (java.util.Map)3195 File (java.io.File)3090 HashSet (java.util.HashSet)2245 Iterator (java.util.Iterator)1591 Test (org.testng.annotations.Test)1074 SQLException (java.sql.SQLException)1046 ResultSet (java.sql.ResultSet)1017 Date (java.util.Date)997 Set (java.util.Set)917 LinkedHashMap (java.util.LinkedHashMap)886 PreparedStatement (java.sql.PreparedStatement)882 Collection (java.util.Collection)751 LinkedList (java.util.LinkedList)677 BufferedReader (java.io.BufferedReader)663 Path (org.apache.hadoop.fs.Path)611