// Path: src/main/java/uk/bl/odin/orcid/domain/CacheManager.java
// public class CacheManager {
// 
// 	private final Cache<SearchKey, OrcidSearchResults> searchCache;
// 
// 	private final Cache<String, OrcidProfile> profileCache;
// 
// 	@Inject
// 	public CacheManager(@Named("OrcidCacheTimeout") Integer timeOutInMinutes,
// 			@Named("OrcidCacheMaxsize") Integer maximumSize) {
// 		searchCache = CacheBuilder.newBuilder().expireAfterWrite(timeOutInMinutes, TimeUnit.MINUTES)
// 				.maximumSize(maximumSize).build();
// 		profileCache = CacheBuilder.newBuilder().expireAfterWrite(timeOutInMinutes, TimeUnit.MINUTES)
// 				.maximumSize(maximumSize).build();
// 	}
// 
// 	public Cache<SearchKey, OrcidSearchResults> getSearchCache() {
// 		return searchCache;
// 	}
// 
// 	public Cache<String, OrcidProfile> getProfilecache() {
// 		return profileCache;
// 	}
// 
// }
// 
// Path: src/main/java/uk/bl/odin/orcid/guice/SelfInjectingServerResource.java
// public abstract class SelfInjectingServerResource extends ServerResource {
// 
// 	/**
// 	 * Implemented by DI framework-specific code. For example, with Guice, the
// 	 * statically-injected MembersInjector just calls
// 	 * {@code injector.injectMembers(object)}.
// 	 */
// 	public interface MembersInjector {
// 		void injectMembers(Object object);
// 	}
// 
// 	/**
// 	 * Subclasseses overriding this method must call {@code super.doInit()}
// 	 * first.
// 	 */
// 	protected void doInit() {
// 		ensureInjected(theMembersInjector);
// 	}
// 
// 	@Inject
// 	private void injected() { // NOPMD
// 		injected.set(true);
// 	}
// 
// 	void ensureInjected(MembersInjector membersInjector) {
// 		if (injected.compareAndSet(false, true)) {
// 			membersInjector.injectMembers(this);
// 		}
// 	}
// 
// 	/**
// 	 * Whether we've been injected yet. This protects against multiple injection
// 	 * of a subclass that gets injected before doInit is called.
// 	 */
// 	private final AtomicBoolean injected = new AtomicBoolean(false);
// 
// 	/**
// 	 * Must be statically injected by DI framework.
// 	 */
// 	@Inject
// 	private static volatile MembersInjector theMembersInjector;
// }


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import javax.inject.Inject;
import javax.xml.bind.JAXBElement;
import org.restlet.data.Status;
import org.restlet.ext.jackson.JacksonRepresentation;
import org.restlet.representation.Representation;
import org.restlet.resource.Get;
import org.restlet.resource.ResourceException;
import uk.bl.odin.orcid.client.OrcidPublicClient;
import uk.bl.odin.orcid.client.SearchKey;
import uk.bl.odin.orcid.client.SearchType;
import uk.bl.odin.orcid.client.constants.OrcidExternalIdentifierType;
import uk.bl.odin.orcid.client.constants.OrcidSearchField;
import uk.bl.odin.orcid.domain.CacheManager;
import uk.bl.odin.orcid.guice.SelfInjectingServerResource;
import uk.bl.odin.orcid.schema.messages.onepointtwo.OrcidId;
import uk.bl.odin.orcid.schema.messages.onepointtwo.OrcidSearchResult;
import uk.bl.odin.orcid.schema.messages.onepointtwo.OrcidSearchResults;
import com.google.common.base.Joiner;
			this.setStatus(Status.SERVER_ERROR_BAD_GATEWAY, e.getMessage());
			return null;
		}
	}

	// http://datatables.net/release-datatables/examples/data_sources/server_side.html
	// http://datatables.net/release-datatables/examples/ajax/objects.html

	// this one
	// http://datatables.net/forums/discussion/16675/twitter-bootstrap-3
	public static class DatatableResults {
		public List<BriefResult> aaData = new ArrayList<BriefResult>();
		public int iTotalRecords = 0;
		public int iTotalDisplayRecords = 0;
		public int sEcho = 0;
	}

	public static class BriefResult {
		public String name;
		public String orcid;
		public String link;
	}

	private String getValueFromOrcidId(OrcidId orcidId, String name) throws IOException {
		for (JAXBElement<String> element : orcidId.getContent()) {
			if (element.getName().getLocalPart().equals(name)) {
				return element.getValue();
			}
		}

// Path: src/main/java/uk/bl/odin/orcid/domain/CacheManager.java
// public class CacheManager {
// 
// 	private final Cache<SearchKey, OrcidSearchResults> searchCache;
// 
// 	private final Cache<String, OrcidProfile> profileCache;
// 
// 	@Inject
// 	public CacheManager(@Named("OrcidCacheTimeout") Integer timeOutInMinutes,
// 			@Named("OrcidCacheMaxsize") Integer maximumSize) {
// 		searchCache = CacheBuilder.newBuilder().expireAfterWrite(timeOutInMinutes, TimeUnit.MINUTES)
// 				.maximumSize(maximumSize).build();
// 		profileCache = CacheBuilder.newBuilder().expireAfterWrite(timeOutInMinutes, TimeUnit.MINUTES)
// 				.maximumSize(maximumSize).build();
// 	}
// 
// 	public Cache<SearchKey, OrcidSearchResults> getSearchCache() {
// 		return searchCache;
// 	}
// 
// 	public Cache<String, OrcidProfile> getProfilecache() {
// 		return profileCache;
// 	}
// 
// }
// 
// Path: src/main/java/uk/bl/odin/orcid/guice/SelfInjectingServerResource.java
// public abstract class SelfInjectingServerResource extends ServerResource {
// 
// 	/**
// 	 * Implemented by DI framework-specific code. For example, with Guice, the
// 	 * statically-injected MembersInjector just calls
// 	 * {@code injector.injectMembers(object)}.
// 	 */
// 	public interface MembersInjector {
// 		void injectMembers(Object object);
// 	}
// 
// 	/**
// 	 * Subclasseses overriding this method must call {@code super.doInit()}
// 	 * first.
// 	 */
// 	protected void doInit() {
// 		ensureInjected(theMembersInjector);
// 	}
// 
// 	@Inject
// 	private void injected() { // NOPMD
// 		injected.set(true);
// 	}
// 
// 	void ensureInjected(MembersInjector membersInjector) {
// 		if (injected.compareAndSet(false, true)) {
// 			membersInjector.injectMembers(this);
// 		}
// 	}
// 
// 	/**
// 	 * Whether we've been injected yet. This protects against multiple injection
// 	 * of a subclass that gets injected before doInit is called.
// 	 */
// 	private final AtomicBoolean injected = new AtomicBoolean(false);
// 
// 	/**
// 	 * Must be statically injected by DI framework.
// 	 */
// 	@Inject
// 	private static volatile MembersInjector theMembersInjector;
// }


// Path: src/main/java/uk/bl/odin/orcid/rest/report/OrcidDataCentreReportResource.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import javax.inject.Inject;
import javax.xml.bind.JAXBElement;
import org.restlet.data.Status;
import org.restlet.ext.jackson.JacksonRepresentation;
import org.restlet.representation.Representation;
import org.restlet.resource.Get;
import org.restlet.resource.ResourceException;
import uk.bl.odin.orcid.client.OrcidPublicClient;
import uk.bl.odin.orcid.client.SearchKey;
import uk.bl.odin.orcid.client.SearchType;
import uk.bl.odin.orcid.client.constants.OrcidExternalIdentifierType;
import uk.bl.odin.orcid.client.constants.OrcidSearchField;
import uk.bl.odin.orcid.domain.CacheManager;
import uk.bl.odin.orcid.guice.SelfInjectingServerResource;
import uk.bl.odin.orcid.schema.messages.onepointtwo.OrcidId;
import uk.bl.odin.orcid.schema.messages.onepointtwo.OrcidSearchResult;
import uk.bl.odin.orcid.schema.messages.onepointtwo.OrcidSearchResults;
import com.google.common.base.Joiner;

			this.setStatus(Status.SERVER_ERROR_BAD_GATEWAY, e.getMessage());
			return null;
		}
	}

	// http://datatables.net/release-datatables/examples/data_sources/server_side.html
	// http://datatables.net/release-datatables/examples/ajax/objects.html

	// this one
	// http://datatables.net/forums/discussion/16675/twitter-bootstrap-3
	public static class DatatableResults {
		public List<BriefResult> aaData = new ArrayList<BriefResult>();
		public int iTotalRecords = 0;
		public int iTotalDisplayRecords = 0;
		public int sEcho = 0;
	}

	public static class BriefResult {
		public String name;
		public String orcid;
		public String link;
	}

	private String getValueFromOrcidId(OrcidId orcidId, String name) throws IOException {
		for (JAXBElement<String> element : orcidId.getContent()) {
			if (element.getName().getLocalPart().equals(name)) {
				return element.getValue();
			}
		}

		throw new IOException("Unable to find JAXBElement with name '" + name + "'");