<commit_before>package ca.corefacility.bioinformatics.irida.ria.web.projects;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.HttpClientErrorException;

import ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException;
import ca.corefacility.bioinformatics.irida.model.project.Project;
import ca.corefacility.bioinformatics.irida.model.remote.RemoteRelatedProject;
import ca.corefacility.bioinformatics.irida.ria.utilities.CacheObject;
import ca.corefacility.bioinformatics.irida.ria.utilities.RemoteObjectCache;
import ca.corefacility.bioinformatics.irida.service.RemoteRelatedProjectService;
import ca.corefacility.bioinformatics.irida.service.remote.ProjectRemoteService;

@Controller
@RequestMapping("/projects/remote")
public class RemoteProjectsController {
	private static final Logger logger = LoggerFactory.getLogger(RemoteProjectsController.class);

	public static final String REMOTE_PROJECT_VIEW = "remote/project";

	private final ProjectRemoteService projectRemoteService;
	private final RemoteRelatedProjectService remoteRelatedProjectService;
	private RemoteObjectCache<Project> projectCache;

	@Autowired
	public RemoteProjectsController(ProjectRemoteService projectRemoteService,
			RemoteRelatedProjectService remoteRelatedProjectService, RemoteObjectCache<Project> projectCache) {
		this.projectRemoteService = projectRemoteService;
		this.remoteRelatedProjectService = remoteRelatedProjectService;
		this.projectCache = projectCache;
	}

	/**
	 * Read a remote project by its internal {@link RemoteRelatedProject} ID
	 * 
	 * @param remoteProjectId
	 *            the internal ID of the {@link RemoteRelatedProject}
	 * @return A map containing info about the remote projcet read from the
	 *         remote API
	 */
	@RequestMapping("/ajax/related/{remoteProjectId}")
	@ResponseBody
	public Map<String, Object> readRemoteRelatedProject(@PathVariable Long remoteProjectId) {
		RemoteRelatedProject remoteRelatedProject = remoteRelatedProjectService.read(remoteProjectId);
		logger.trace("Reading remote project from service " + remoteRelatedProject.getRemoteAPI());
		Map<String, Object> map = new HashMap<>();
		Project project = projectRemoteService.read(remoteRelatedProject);

		Integer cacheId = projectCache.addResource(project, remoteRelatedProject.getRemoteAPI());

		map.put("id", project.getId());
		map.put("name", project.getName());
		map.put("remoteId", cacheId);

		return map;
	}

	/**
	 * Get the info page about a given {@link Project}
	 * 
	 * @param projectCacheId
	 *            The {@link RemoteObjectCache} id of the project
	 * @param model
	 *            Model for the view
	 * @return the name of the remote project view page
	 */
	@RequestMapping("/{projectCacheId}")
	public String readRemoteProject(@PathVariable Integer projectCacheId, Model model) {
		CacheObject<Project> readResource = projectCache.readResource(projectCacheId);
		model.addAttribute("project", readResource.getResource());
		model.addAttribute("api", readResource.getAPI());

		return REMOTE_PROJECT_VIEW;
	}

	/**
	 * Handle an {@link IridaOAuthException} and return a status message
	 * 
	 * @param ex
	 *            The {@link IridaOAuthException} thrown
	 * @return an invalid_token string
	 */
	@ExceptionHandler(IridaOAuthException.class)
	@ResponseBody
	public String handleOAuthException(IridaOAuthException ex) {
		return "invalid_token";
	}

	/**
	 * Handle a {@link HttpClientErrorException} and if the response was HTTP403
	 * respond with a message rather than throwing an errror
	 * 
	 * @param e
	 *            the thrown HttpClientErrorException
	 * @return "forbidden" for a 403 error, rethrow the exception otherwise
	 */
	@ExceptionHandler(HttpClientErrorException.class)
	@ResponseBody
	public String handleForbiddenResponse(HttpClientErrorException e) {
		if (e.getStatusCode() == HttpStatus.FORBIDDEN) {
			return "forbidden";
		} else {
			throw e;
		}
	}
}<commit_msg>removed the details page for remoteprojectscontroller<commit_after>package ca.corefacility.bioinformatics.irida.ria.web.projects;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.HttpClientErrorException;

import com.google.common.collect.ImmutableMap;

import ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException;
import ca.corefacility.bioinformatics.irida.model.project.Project;
import ca.corefacility.bioinformatics.irida.model.remote.RemoteRelatedProject;
import ca.corefacility.bioinformatics.irida.service.RemoteRelatedProjectService;
import ca.corefacility.bioinformatics.irida.service.remote.ProjectRemoteService;

@Controller
@RequestMapping("/projects/remote")
public class RemoteProjectsController {
	private static final Logger logger = LoggerFactory.getLogger(RemoteProjectsController.class);

	public static final String REMOTE_PROJECT_VIEW = "remote/project";

	private final ProjectRemoteService projectRemoteService;
	private final RemoteRelatedProjectService remoteRelatedProjectService;

	@Autowired
	public RemoteProjectsController(ProjectRemoteService projectRemoteService,
			RemoteRelatedProjectService remoteRelatedProjectService) {
		this.projectRemoteService = projectRemoteService;
		this.remoteRelatedProjectService = remoteRelatedProjectService;
	}

	/**
	 * Read a remote project by its internal {@link RemoteRelatedProject} ID
	 * 
	 * @param remoteProjectId
	 *            the internal ID of the {@link RemoteRelatedProject}
	 * @return A map containing info about the remote projcet read from the
	 *         remote API
	 */
	@RequestMapping("/ajax/related/{remoteProjectId}")
	@ResponseBody
	public Map<String, Object> readRemoteRelatedProject(@PathVariable Long remoteProjectId) {
		RemoteRelatedProject remoteRelatedProject = remoteRelatedProjectService.read(remoteProjectId);
		logger.trace("Reading remote project from service " + remoteRelatedProject.getRemoteAPI());
		Map<String, Object> map = new HashMap<>();
		Project project = projectRemoteService.read(remoteRelatedProject);

		map.put("id", project.getId());
		map.put("name", project.getName());

		return map;
	}

	/**
	 * Handle an {@link IridaOAuthException} and return a status message
	 * 
	 * @param ex
	 *            The {@link IridaOAuthException} thrown
	 * @return an invalid_token string
	 */
	@ExceptionHandler(IridaOAuthException.class)
	@ResponseBody
	public Map<String, Object> handleOAuthException(IridaOAuthException ex) {
		return ImmutableMap.of("status", "invalid_token");
	}

	/**
	 * Handle a {@link HttpClientErrorException} and if the response was HTTP403
	 * respond with a message rather than throwing an errror
	 * 
	 * @param e
	 *            the thrown HttpClientErrorException
	 * @return "forbidden" for a 403 error, rethrow the exception otherwise
	 */
	@ExceptionHandler(HttpClientErrorException.class)
	@ResponseBody
	public Map<String, Object> handleForbiddenResponse(HttpClientErrorException e) {
		if (e.getStatusCode() == HttpStatus.FORBIDDEN) {
			return ImmutableMap.of("status", "forbidden");
		} else {
			throw e;
		}
	}
}
{'fraction_non_alphanumeric': 0.0893611732537907, 'fraction_numerical': 0.0019885657469550086, 'mean_word_length': 5.606732348111659, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2659194', 'n_tokens_mistral': 2307, 'n_tokens_neox': 2127, 'n_words': 500}