use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.
the class NextprotAuth0EndpointImpl method fetchUser.
@Cacheable("user-auth")
public Auth0User fetchUser(String accessToken) throws IOException, JSONException {
Resty resty = new Resty();
String userInfoUri = getUserInfoUri(accessToken);
JSONResource json = resty.json(userInfoUri);
return new Auth0User(json.toObject());
}
use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.
the class TerminologyDaoImpl method findTerminologyByAccession.
@Override
// SHOULD USE findTermByAccessionAndTerminology
@Cacheable("terminology-by-accession")
public CvTerm findTerminologyByAccession(String accession) {
Set<String> acs = new HashSet<>();
acs.add(accession);
SqlParameterSource params = new MapSqlParameterSource("accessions", acs);
List<CvTerm> terms = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("terminology-by-acs"), params, new DbTermRowMapper());
if (terms.size() == 0)
return null;
else if (terms.size() > 1) {
throw new NextProtException("Found " + terms.size() + " terms that corresponds to the same accession. Use the method findTerminologyByAccessionForTerminology (accession, terminology) instead");
}
return terms.get(0);
}
use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.
the class EntryPageServiceImpl method hasContentForPageDisplay.
@Cacheable(value = "page-display", key = "#entryName")
@Override
public Map<String, Boolean> hasContentForPageDisplay(@ValidEntry String entryName) {
Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryName).withEverything());
Map<String, Boolean> map = new HashMap<>();
for (PageViewFactory page : PageViewFactory.values()) {
PageView pv = page.getPageView();
map.put(pv.getLabel(), pv.doDisplayPage(entry));
}
return map;
}
use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.
the class GitHubServiceImpl method getTree.
@Override
@Cacheable(value = "github-tree")
public GHTree getTree() {
try {
GitHub github = getGitHubConnection();
GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
return repo.getTreeRecursive(githubDocBranch, 1);
} catch (IOException e) {
e.printStackTrace();
throw new NextProtException("Documentation not available, sorry for the inconvenience");
}
}
use of org.springframework.cache.annotation.Cacheable in project nextprot-api by calipho-sib.
the class GitHubServiceImpl method getPage.
@Override
@Cacheable(value = "github-pages")
public String getPage(String folder, String page) {
String finalPage = page;
if ("news".equalsIgnoreCase(folder)) {
finalPage = getCorrespondingPageForNews(page);
}
try {
GitHub github = getGitHubConnection();
GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
GHContent content = null;
String extension = ".md";
if (folder.contains("json")) {
// if folder contains json
extension = ".json";
}
content = repo.getFileContent(folder + "/" + finalPage + extension, githubDocBranch);
return content.getContent();
} catch (IOException e) {
e.printStackTrace();
throw new NextProtException("Documentation not available, sorry for the inconvenience");
}
}
Aggregations