package io.spacedog.client.log;

import java.util.List;
import java.util.Set;

import org.joda.time.DateTime;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Sets;

import io.spacedog.client.credentials.Credentials;

@JsonIgnoreProperties(ignoreUnknown = true)
public final class LogItem {
	public String method;
	public String path;
	public DateTime receivedAt;
	public int processedIn;
	public int status;
	public Credentials credentials;
	public List<String> headers;
	public List<String> parameters;
	public ObjectNode payload;
	public ObjectNode response;

	public String getParameter(String name) {
		for (String string : parameters) {
			String[] parts = string.split(": ", 2);
			if (parts[0].equals(name))
				return parts[1];
		}
		return null;
	}

	public Set<String> getHeader(String name) {
		Set<String> values = Sets.newHashSet();
		for (String string : headers) {
			String[] parts = string.split(": ", 2);
			if (parts[0].equals(name))
				values.add(parts[1]);
		}
		return values;
	}
}
@@ -265,60 +265,8 @@
 s;%0A%0A
-import io.spacedog.client.credentials.Credentials;%0A%0A
 @Jso
@@ -471,16 +471,22 @@
 dentials
+Resume
  credent
@@ -1052,10 +1052,129 @@
 lues;%0A%09%7D
+%0A%0A%09public static class CredentialsResume %7B%0A%09%09public String id;%0A%09%09public String username;%0A%09%09public Set%3CString%3E roles;%0A%09%7D
 %0A%7D

Fix LogItem to only map credentials id, username and roles