Added generic type to Transaction class to remove warnings

This commit is contained in:
Stian Thorgersen 2013-08-15 13:30:38 +01:00
parent 5f90150058
commit 54f3f7a922
10 changed files with 36 additions and 36 deletions

View file

@ -41,7 +41,7 @@ public class PublicRealmResource {
@NoCache
@Produces("application/json")
public PublishedRealmRepresentation getRealm(@PathParam("realm") String id) {
return new Transaction() {
return new Transaction<PublishedRealmRepresentation>() {
protected PublishedRealmRepresentation callImpl() {
return realmRep(realm, uriInfo);
}
@ -53,7 +53,7 @@ public class PublicRealmResource {
@Path("html")
@Produces("text/html")
public String getRealmHtml(@PathParam("realm") String id) {
return new Transaction() {
return new Transaction<String>() {
protected String callImpl() {
StringBuffer html = new StringBuffer();

View file

@ -53,7 +53,7 @@ public class RealmsResource {
@Path("{realm}/tokens")
public TokenService getTokenService(final @PathParam("realm") String id) {
return new Transaction(false) {
return new Transaction<TokenService>(false) {
@Override
protected TokenService callImpl() {
RealmManager realmManager = new RealmManager(session);
@ -72,7 +72,7 @@ public class RealmsResource {
@Path("{realm}")
public PublicRealmResource getRealmResource(final @PathParam("realm") String id) {
return new Transaction(false) {
return new Transaction<PublicRealmResource>(false) {
@Override
protected PublicRealmResource callImpl() {
RealmManager realmManager = new RealmManager(session);

View file

@ -79,7 +79,7 @@ public class SaasService {
@NoCache
public Response keepalive(final @Context HttpHeaders headers) {
logger.info("keepalive");
return new Transaction() {
return new Transaction<Response>() {
@Override
public Response callImpl() {
RealmManager realmManager = new RealmManager(session);
@ -101,7 +101,7 @@ public class SaasService {
@Produces("application/json")
@NoCache
public Response whoAmI(final @Context HttpHeaders headers) {
return new Transaction() {
return new Transaction<Response>() {
@Override
public Response callImpl() {
RealmManager realmManager = new RealmManager(session);
@ -122,7 +122,7 @@ public class SaasService {
@Produces("application/javascript")
@NoCache
public String isLoggedIn(final @Context HttpHeaders headers) {
return new Transaction() {
return new Transaction<String>() {
@Override
public String callImpl() {
logger.info("WHOAMI Javascript start.");
@ -152,7 +152,7 @@ public class SaasService {
@Path("admin/realms")
public RealmsAdminResource getRealmsAdmin(@Context final HttpHeaders headers) {
return new Transaction(false) {
return new Transaction<RealmsAdminResource>(false) {
@Override
protected RealmsAdminResource callImpl() {
RealmManager realmManager = new RealmManager(session);
@ -239,7 +239,7 @@ public class SaasService {
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response processLogin(final MultivaluedMap<String, String> formData) {
logger.info("processLogin start");
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
RealmManager realmManager = new RealmManager(session);
@ -283,7 +283,7 @@ public class SaasService {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response register(final UserRepresentation newUser) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
RealmManager realmManager = new RealmManager(session);
@ -302,7 +302,7 @@ public class SaasService {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response processRegister(final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
RealmManager realmManager = new RealmManager(session);

View file

@ -91,7 +91,7 @@ public class SocialResource {
@GET
@Path("callback")
public Response callback() throws URISyntaxException {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
Map<String, String[]> queryParams = getQueryParams();

View file

@ -118,7 +118,7 @@ public class TokenService {
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response grantIdentityToken(final MultivaluedMap<String, String> form) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
String username = form.getFirst(AuthenticationManager.FORM_USERNAME);
if (username == null) {
@ -151,7 +151,7 @@ public class TokenService {
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response grantAccessToken(final MultivaluedMap<String, String> form) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
String username = form.getFirst(AuthenticationManager.FORM_USERNAME);
if (username == null) {
@ -185,7 +185,7 @@ public class TokenService {
public Response processLogin(@QueryParam("client_id") final String clientId, @QueryParam("scope") final String scopeParam,
@QueryParam("state") final String state, @QueryParam("redirect_uri") final String redirect,
final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);
@ -229,7 +229,7 @@ public class TokenService {
public Response processRegister(@QueryParam("client_id") final String clientId,
@QueryParam("scope") final String scopeParam, @QueryParam("state") final String state,
@QueryParam("redirect_uri") final String redirect, final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);
@ -310,7 +310,7 @@ public class TokenService {
@POST
@Produces("application/json")
public Response accessCodeToToken(final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
logger.info("accessRequest <---");
if (!realm.isEnabled()) {
@ -438,7 +438,7 @@ public class TokenService {
public Response loginPage(final @QueryParam("response_type") String responseType,
final @QueryParam("redirect_uri") String redirect, final @QueryParam("client_id") String clientId,
final @QueryParam("scope") String scopeParam, final @QueryParam("state") String state) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);
@ -486,7 +486,7 @@ public class TokenService {
public Response registerPage(final @QueryParam("response_type") String responseType,
final @QueryParam("redirect_uri") String redirect, final @QueryParam("client_id") String clientId,
final @QueryParam("scope") String scopeParam, final @QueryParam("state") String state) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);
@ -517,7 +517,7 @@ public class TokenService {
@GET
@NoCache
public Response logout(final @QueryParam("redirect_uri") String redirectUri) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
// todo do we care if anybody can trigger this?
@ -537,7 +537,7 @@ public class TokenService {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response processOAuth(final MultivaluedMap<String, String> formData) {
return new Transaction() {
return new Transaction<Response>() {
protected Response callImpl() {
OAuthFlows oauth = Flows.oauth(realm, request, uriInfo, authManager, tokenManager);

View file

@ -13,7 +13,7 @@ import javax.ws.rs.core.Application;
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class Transaction {
public class Transaction<T> {
protected KeycloakSession session;
protected KeycloakTransaction transaction;
protected boolean closeSession;
@ -83,7 +83,7 @@ public class Transaction {
}
}
protected <T> T callImpl() {
protected T callImpl() {
return null;
}
@ -91,7 +91,7 @@ public class Transaction {
* Will not begin or end a transaction or close a session if the transaction was already active when called
*
*/
public <T> T call() {
public T call() {
boolean wasActive = transaction.isActive();
if (!wasActive) transaction.begin();
try {

View file

@ -36,7 +36,7 @@ public class ApplicationResource {
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public void update(final ApplicationRepresentation rep) {
new Transaction() {
new Transaction<Void>() {
@Override
protected void runImpl() {
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
@ -50,7 +50,7 @@ public class ApplicationResource {
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public ApplicationRepresentation getResource(final @PathParam("id") String id) {
return new Transaction() {
return new Transaction<ApplicationRepresentation>() {
@Override
protected ApplicationRepresentation callImpl() {
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));

View file

@ -42,7 +42,7 @@ public class ApplicationsResource {
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public List<ApplicationRepresentation> getResources() {
return new Transaction() {
return new Transaction<List<ApplicationRepresentation>>() {
@Override
protected List<ApplicationRepresentation> callImpl() {
List<ApplicationRepresentation> rep = new ArrayList<ApplicationRepresentation>();
@ -59,7 +59,7 @@ public class ApplicationsResource {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response createResource(final @Context UriInfo uriInfo, final ApplicationRepresentation rep) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
@ -71,7 +71,7 @@ public class ApplicationsResource {
@Path("{id}")
public ApplicationResource getResource(final @PathParam("id") String id) {
return new Transaction(false) {
return new Transaction<ApplicationResource>(false) {
@Override
protected ApplicationResource callImpl() {
ApplicationModel applicationModel = realm.getApplicationById(id);

View file

@ -49,7 +49,7 @@ public class RealmAdminResource {
@NoCache
@Produces("application/json")
public RealmRepresentation getRealm() {
return new Transaction() {
return new Transaction<RealmRepresentation>() {
@Override
protected RealmRepresentation callImpl() {
return new RealmManager(session).toRepresentation(realm);
@ -63,7 +63,7 @@ public class RealmAdminResource {
@NoCache
@Produces("application/json")
public List<RoleRepresentation> getRoles() {
return new Transaction() {
return new Transaction<List<RoleRepresentation>>() {
@Override
protected List<RoleRepresentation> callImpl() {
List<RoleModel> roleModels = realm.getRoles();
@ -95,7 +95,7 @@ public class RealmAdminResource {
@NoCache
@Produces("application/json")
public RoleRepresentation getRole(final @PathParam("id") String id) {
return new Transaction() {
return new Transaction<RoleRepresentation>() {
@Override
protected RoleRepresentation callImpl() {
RoleModel roleModel = realm.getRoleById(id);
@ -132,7 +132,7 @@ public class RealmAdminResource {
@POST
@Consumes("application/json")
public Response createRole(final @Context UriInfo uriInfo, final RoleRepresentation rep) {
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
if (realm.getRole(rep.getName()) != null) {

View file

@ -54,7 +54,7 @@ public class RealmsAdminResource {
@NoCache
@Produces("application/json")
public List<RealmRepresentation> getRealms() {
return new Transaction() {
return new Transaction<List<RealmRepresentation>>() {
@Override
protected List<RealmRepresentation> callImpl() {
logger.info(("getRealms()"));
@ -81,7 +81,7 @@ public class RealmsAdminResource {
@Consumes("application/json")
public Response importRealm(@Context final UriInfo uriInfo, final RealmRepresentation rep) {
logger.info("importRealm: " + rep.getRealm());
return new Transaction() {
return new Transaction<Response>() {
@Override
protected Response callImpl() {
RealmManager realmManager = new RealmManager(session);
@ -96,7 +96,7 @@ public class RealmsAdminResource {
@Path("{id}")
public RealmAdminResource getRealmAdmin(@Context final HttpHeaders headers,
@PathParam("id") final String id) {
return new Transaction(false) {
return new Transaction<RealmAdminResource>(false) {
@Override
protected RealmAdminResource callImpl() {
RealmManager realmManager = new RealmManager(session);