// Path: src/main/java/uk/bl/odin/orcid/doi/DOIPrefixMapper.java
// @Singleton
// public class DOIPrefixMapper {
// 
// 	// name -> doi list
// 	private final ImmutableMultimap<String, String> publisherMap;
// 	private final ImmutableMultimap<String, String> datacentreMap;
// 
// 	@Inject
// 	public DOIPrefixMapper() {
// 		publisherMap = loadPublisherMap("doi-prefix-publishers.csv");
// 		datacentreMap = loadBasicDatacentreMap("datacentre-prefixes.json");
// 	}
// 
// 	private ImmutableMultimap<String, String> loadBasicDatacentreMap(String file) {
// 		Multimap<String, String> m = LinkedHashMultimap.create();
// 		ObjectMapper mapper = new ObjectMapper();
// 		try {
// 			List<DatacentrePrefixMapping> prefixes = mapper.readValue(getClass().getResourceAsStream(file),
// 					new TypeReference<List<DatacentrePrefixMapping>>() {
// 					});
// 			for (DatacentrePrefixMapping mapping : prefixes) {
// 				m.putAll(mapping.datacentre, mapping.prefixes);
// 			}
// 		} catch (IOException e) {
// 			throw new RuntimeException(e);
// 		}
// 		return ImmutableMultimap.copyOf(m);
// 	}
// 
// 	private ImmutableMultimap<String, String> loadPublisherMap(String file) {
// 		// todo make sortedsetmultimap
// 		Multimap<String, String> temp = LinkedHashMultimap.create();
// 		CsvMapper mapper = new CsvMapper();
// 		mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
// 		try {
// 			MappingIterator<Object[]> it = mapper.reader(Object[].class).readValues(
// 					getClass().getResourceAsStream(file));
// 			while (it.hasNext()) {
// 				Object[] row = it.next();
// 				if (row.length > 1 && (row[0] != null && row[1] != null)
// 						&& (!row[0].toString().isEmpty() && !row[1].toString().isEmpty())) {
// 					temp.put(row[1].toString().trim(), row[0].toString().trim());
// 				}
// 			}
// 		} catch (IOException e) {
// 			throw new RuntimeException(e);
// 		}
// 		return ImmutableMultimap.copyOf(temp);
// 	}
// 
// 	public ImmutableMultimap<String, String> getDatacentreMap() {
// 		return datacentreMap;
// 	}
// 
// 	/**
// 	 * A map of Publisher name -> DOI prefixes
// 	 * 
// 	 * @return sorted by publisher name
// 	 */
// 	public ImmutableMultimap<String, String> getPublisherMap() {
// 		return publisherMap;
// 	}
// 
// 	public static class DatacentrePrefixMapping {
// 		public String datacentre;
// 		public List<String> prefixes;
// 	}
// 
// }
// 
// 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.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import org.restlet.ext.jackson.JacksonRepresentation;
import org.restlet.representation.Representation;
import org.restlet.resource.Get;
import uk.bl.odin.orcid.doi.DOIPrefixMapper;
import uk.bl.odin.orcid.guice.SelfInjectingServerResource;
import com.google.common.base.Joiner;
import com.google.common.collect.Multimap;
package uk.bl.odin.orcid.rest.report;






public class PublisherDOIPrefixResource extends SelfInjectingServerResource {

	@Inject
	DOIPrefixMapper mapper;

	@Get("json")
// Path: src/main/java/uk/bl/odin/orcid/doi/DOIPrefixMapper.java
// @Singleton
// public class DOIPrefixMapper {
// 
// 	// name -> doi list
// 	private final ImmutableMultimap<String, String> publisherMap;
// 	private final ImmutableMultimap<String, String> datacentreMap;
// 
// 	@Inject
// 	public DOIPrefixMapper() {
// 		publisherMap = loadPublisherMap("doi-prefix-publishers.csv");
// 		datacentreMap = loadBasicDatacentreMap("datacentre-prefixes.json");
// 	}
// 
// 	private ImmutableMultimap<String, String> loadBasicDatacentreMap(String file) {
// 		Multimap<String, String> m = LinkedHashMultimap.create();
// 		ObjectMapper mapper = new ObjectMapper();
// 		try {
// 			List<DatacentrePrefixMapping> prefixes = mapper.readValue(getClass().getResourceAsStream(file),
// 					new TypeReference<List<DatacentrePrefixMapping>>() {
// 					});
// 			for (DatacentrePrefixMapping mapping : prefixes) {
// 				m.putAll(mapping.datacentre, mapping.prefixes);
// 			}
// 		} catch (IOException e) {
// 			throw new RuntimeException(e);
// 		}
// 		return ImmutableMultimap.copyOf(m);
// 	}
// 
// 	private ImmutableMultimap<String, String> loadPublisherMap(String file) {
// 		// todo make sortedsetmultimap
// 		Multimap<String, String> temp = LinkedHashMultimap.create();
// 		CsvMapper mapper = new CsvMapper();
// 		mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
// 		try {
// 			MappingIterator<Object[]> it = mapper.reader(Object[].class).readValues(
// 					getClass().getResourceAsStream(file));
// 			while (it.hasNext()) {
// 				Object[] row = it.next();
// 				if (row.length > 1 && (row[0] != null && row[1] != null)
// 						&& (!row[0].toString().isEmpty() && !row[1].toString().isEmpty())) {
// 					temp.put(row[1].toString().trim(), row[0].toString().trim());
// 				}
// 			}
// 		} catch (IOException e) {
// 			throw new RuntimeException(e);
// 		}
// 		return ImmutableMultimap.copyOf(temp);
// 	}
// 
// 	public ImmutableMultimap<String, String> getDatacentreMap() {
// 		return datacentreMap;
// 	}
// 
// 	/**
// 	 * A map of Publisher name -> DOI prefixes
// 	 * 
// 	 * @return sorted by publisher name
// 	 */
// 	public ImmutableMultimap<String, String> getPublisherMap() {
// 		return publisherMap;
// 	}
// 
// 	public static class DatacentrePrefixMapping {
// 		public String datacentre;
// 		public List<String> prefixes;
// 	}
// 
// }
// 
// 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/PublisherDOIPrefixResource.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.inject.Inject;
import org.restlet.ext.jackson.JacksonRepresentation;
import org.restlet.representation.Representation;
import org.restlet.resource.Get;
import uk.bl.odin.orcid.doi.DOIPrefixMapper;
import uk.bl.odin.orcid.guice.SelfInjectingServerResource;
import com.google.common.base.Joiner;
import com.google.common.collect.Multimap;

package uk.bl.odin.orcid.rest.report;






public class PublisherDOIPrefixResource extends SelfInjectingServerResource {

	@Inject
	DOIPrefixMapper mapper;

	@Get("json")
	public Representation getPrefixMap() {