All Downloads are FREE. Search and download functionalities are using the official Maven repository.

airbrake.AirbrakeNotice Maven / Gradle / Ivy

// Modified or written by Luca Marrocco for inclusion with airbrake.
// Copyright (c) 2009 Luca Marrocco.
// Licensed under the Apache License, Version 2.0 (the "License")

package airbrake;

import static java.util.Arrays.*;

import java.util.*;

public class AirbrakeNotice {

	private final String apiKey;

	private final String errorMessage;

	private Backtrace backtrace = new Backtrace(asList("backtrace is empty"));

	private String projectRoot;

	private String environmentName;

	private final Map environment = new TreeMap();

	private Map request = new TreeMap();

	private Map session = new TreeMap();

	private String errorClass;

	private boolean hasRequest = false;

	private final String url;

	private final String component;

	public AirbrakeNotice(final String apiKey, String projectRoot, String environmentName, final String errorMessage, String errorClass, final Backtrace backtrace, final Map request, final Map session, final Map environment,
			final List environmentFilters, boolean hasRequest, String url, String component) {
		this.apiKey = apiKey;
		this.projectRoot = projectRoot;
		this.environmentName = environmentName;
		this.errorClass = errorClass;
		this.errorMessage = errorMessage;
		this.backtrace = backtrace;
		this.request = request;
		this.session = session;
		this.hasRequest = hasRequest;
		this.url = url;
		this.component = component;
		filter(environment, environmentFilters);
	}

	public String apiKey() {
		return apiKey;
	}

	public Backtrace backtrace() {
		return backtrace;
	}

	public String component() {
		return component;
	}

	public String env() {
		return environmentName;
	}

	public Map environment() {
		return environment;
	}

	public String errorClass() {
		return errorClass;
	}

	public String errorMessage() {
		return errorMessage;
	}

	private void filter(final Map environment, final List environmentFilters) {
		for (final String key : environment.keySet()) {
			if (!matches(environmentFilters, key)) {
				this.environment.put(key, environment.get(key));
			}
		}
	}

	public boolean hasRequest() {
		return hasRequest;
	}

	private boolean matches(final List environmentFilters, final String key) {
		for (final String filter : environmentFilters) {
			if (key.matches(filter))
				return true;
		}
		return false;
	}

	public String projectRoot() {
		return projectRoot;
	}

	public Map request() {
		return request;
	}

	public Map session() {
		return session;
	}

	public String url() {
		return url;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy