Search in sources :

Example 1 with Target

use of org.candlepin.audit.Event.Target in project candlepin by candlepin.

the class QpidConnection method buildAllTopicPublishers.

/**
 * We create all the topic publishers in advance and reuse them for sending.
 * @param pm
 * @throws JMSException
 * @throws NamingException
 */
private void buildAllTopicPublishers(Map<Target, Map<Type, TopicPublisher>> pm) throws JMSException, NamingException {
    for (Target target : Target.values()) {
        Map<Type, TopicPublisher> typeToTpMap = new HashMap<>();
        for (Type type : Type.values()) {
            storeTopicProducer(type, target, typeToTpMap);
        }
        pm.put(target, typeToTpMap);
    }
}
Also used : Target(org.candlepin.audit.Event.Target) Type(org.candlepin.audit.Event.Type) HashMap(java.util.HashMap) TopicPublisher(javax.jms.TopicPublisher)

Example 2 with Target

use of org.candlepin.audit.Event.Target in project candlepin by candlepin.

the class QpidConfigBuilder method buildConfigurationProperties.

/**
 * Qpid JMS client needs to be configured using both properties (method buildBrokerDetails is used)
 * but also needs configuration in JNDI. This method provides the Properties object that is
 * used to configure the Qpid through JNDI. Besides other things, it also must state in advance
 * which Queues (JMS notion) is mapped to which binding keys (AMQP notion)
 * @return Properties object for JNDI
 */
public Properties buildConfigurationProperties() {
    Properties properties = new Properties();
    properties.put("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
    properties.put("connectionfactory.qpidConnectionfactory", "amqp://guest:guest@localhost/test?sync_publish='persistent'&brokerlist='" + config.getString(ConfigProperties.AMQP_CONNECT_STRING) + "'");
    for (Target target : Target.values()) {
        for (Type type : Type.values()) {
            // topic name is the internal key used to find the
            // AMQP topic.
            String name = getTopicName(type, target);
            // this represents the destination
            String destination = getDestination(type, target);
            properties.put("destination." + name, "event/" + destination);
        }
    }
    return properties;
}
Also used : Target(org.candlepin.audit.Event.Target) Type(org.candlepin.audit.Event.Type) Properties(java.util.Properties) ConfigProperties(org.candlepin.config.ConfigProperties)

Example 3 with Target

use of org.candlepin.audit.Event.Target in project candlepin by candlepin.

the class AtomFeedResourceTest method getEvents.

private List<Event> getEvents(int count) {
    List<Event> list = new ArrayList<>(count);
    Target[] targets = Target.values();
    Type[] types = Type.values();
    for (int i = 0; i < count; i++) {
        Event e = new Event();
        e.setTarget(targets[i % targets.length]);
        e.setType(types[i % types.length]);
        e.setTimestamp(new Date());
        e.setPrincipal(new PrincipalData());
        list.add(e);
    }
    return list;
}
Also used : Target(org.candlepin.audit.Event.Target) Type(org.candlepin.audit.Event.Type) PrincipalData(org.candlepin.auth.PrincipalData) ArrayList(java.util.ArrayList) Event(org.candlepin.audit.Event) Date(java.util.Date)

Example 4 with Target

use of org.candlepin.audit.Event.Target in project candlepin by candlepin.

the class EventFilter method fillEventTypeAndTargetFromConfig.

/**
 * Parses the toupes type-target from the config file.
 *
 * @param includes2
 * @param includesConfig
 */
private void fillEventTypeAndTargetFromConfig(Set<EventTypeAndTarget> set, List<String> stringList) {
    for (String item : stringList) {
        if (item.trim().equals("")) {
            continue;
        }
        String[] split = item.split("-");
        if (split.length != 2) {
            throw new IllegalArgumentException("Invalid include/exclude rule: " + item + "Each filter auditing" + "include/exclude must be in format TYPE-TARGET. For example MODIFIED-CONSUMER.");
        }
        try {
            Type type = Enum.valueOf(Type.class, split[0].trim());
            Target target = Enum.valueOf(Target.class, split[1].trim());
            set.add(new EventTypeAndTarget(type, target));
        } catch (Exception ex) {
            throw new IllegalArgumentException("Invalid filtering tuple: " + item + " . Please use only enum values of Type and Target enums, e.g. MODIFIED-CONSUMER");
        }
    }
}
Also used : Type(org.candlepin.audit.Event.Type) Target(org.candlepin.audit.Event.Target)

Aggregations

Target (org.candlepin.audit.Event.Target)4 Type (org.candlepin.audit.Event.Type)4 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 TopicPublisher (javax.jms.TopicPublisher)1 Event (org.candlepin.audit.Event)1 PrincipalData (org.candlepin.auth.PrincipalData)1 ConfigProperties (org.candlepin.config.ConfigProperties)1