Search in sources :

Example 16 with RemoteAPIToken

use of ca.corefacility.bioinformatics.irida.model.RemoteAPIToken in project irida by phac-nml.

the class RemoteAPIController method read.

/**
 * Get an individual remote API's page
 *
 * @param apiId
 *            The ID of the api
 * @param model
 *            Model for the view
 * @param locale
 *            the locale specified by the browser.
 * @return The name of the remote api details page view
 */
@RequestMapping("/{apiId}")
public String read(@PathVariable Long apiId, Model model, Locale locale) {
    RemoteAPI remoteApi = remoteAPIService.read(apiId);
    model.addAttribute("remoteApi", remoteApi);
    try {
        RemoteAPIToken token = tokenService.getToken(remoteApi);
        model.addAttribute("tokenExpiry", dateTimeFormatter.print(token.getExpiryDate(), locale));
    } catch (EntityNotFoundException ex) {
        // Not returning a token here is acceptable. The view will have to
        // handle a state if the token does not exist
        logger.trace("No token for service " + remoteApi);
    }
    return DETAILS_PAGE;
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) RemoteAPIToken(ca.corefacility.bioinformatics.irida.model.RemoteAPIToken) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)

Aggregations

RemoteAPIToken (ca.corefacility.bioinformatics.irida.model.RemoteAPIToken)16 Date (java.util.Date)8 Test (org.junit.Test)7 RemoteAPI (ca.corefacility.bioinformatics.irida.model.RemoteAPI)6 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)5 Transactional (org.springframework.transaction.annotation.Transactional)3 User (ca.corefacility.bioinformatics.irida.model.user.User)2 URI (java.net.URI)2 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)2 OAuthJSONAccessTokenResponse (org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse)2 ClientHttpRequest (org.springframework.http.client.ClientHttpRequest)2 IridaOAuthException (ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException)1 RemoteApiTokenRepository (ca.corefacility.bioinformatics.irida.repositories.RemoteApiTokenRepository)1 UserRepository (ca.corefacility.bioinformatics.irida.repositories.user.UserRepository)1 RemoteAPITokenServiceImpl (ca.corefacility.bioinformatics.irida.service.impl.RemoteAPITokenServiceImpl)1 OAuthClient (org.apache.oltu.oauth2.client.OAuthClient)1 OAuthProblemException (org.apache.oltu.oauth2.common.exception.OAuthProblemException)1 OAuthSystemException (org.apache.oltu.oauth2.common.exception.OAuthSystemException)1 Before (org.junit.Before)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1