Skip to content

Commit

Permalink
refactor: Deprecating api/user endpoint. Adding exta GET api/user/id …
Browse files Browse the repository at this point in the history
…endpoint for easily obtaining user ID

Signed-off-by: Ilya Buziuk <[email protected]>
  • Loading branch information
ibuziuk committed Feb 21, 2023
1 parent b74fba7 commit f5856a7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* Copyright (c) 2012-2023 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -53,6 +53,7 @@ protected void filter(GenericResourceMethod genericResourceMethod, Object[] argu
case "getCurrent":
case "updatePassword":
case "getById":
case "getId":
case "find":
case "getSettings":
// public methods
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* Copyright (c) 2012-2023 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -13,6 +13,7 @@

import static jakarta.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
import static jakarta.ws.rs.core.MediaType.TEXT_PLAIN;
import static jakarta.ws.rs.core.Response.Status.CREATED;
import static org.eclipse.che.api.user.server.Constants.LINK_REL_CURRENT_USER;
import static org.eclipse.che.api.user.server.Constants.LINK_REL_CURRENT_USER_PASSWORD;
Expand Down Expand Up @@ -83,6 +84,22 @@ public UserService(
this.userSelfCreationAllowed = userSelfCreationAllowed;
}

@GET
@Path("/id")
@Produces(TEXT_PLAIN)
@Operation(
summary = "Get current user's id",
responses = {
@ApiResponse(
responseCode = "200",
description =
"The response contains current user's id ('0000-00-0000' is returned for the anonymous user)"),
})
public String getId() {
return userId();
}

@Deprecated
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
Expand Down Expand Up @@ -121,6 +138,7 @@ public Response create(
.build();
}

@Deprecated
@GET
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_CURRENT_USER)
Expand All @@ -140,6 +158,7 @@ public UserDto getCurrent() throws NotFoundException, ServerException {
return linksInjector.injectLinks(asDto(user), getServiceContext());
}

@Deprecated
@POST
@Path("/password")
@Consumes(APPLICATION_FORM_URLENCODED)
Expand All @@ -165,6 +184,7 @@ public void updatePassword(
userManager.update(user);
}

@Deprecated
@GET
@Path("/{id}")
@Produces(APPLICATION_JSON)
Expand All @@ -188,6 +208,7 @@ public UserDto getById(@Parameter(description = "User identifier") @PathParam("i
return linksInjector.injectLinks(asDto(user), getServiceContext());
}

@Deprecated
@GET
@Path("/find")
@Produces(APPLICATION_JSON)
Expand Down Expand Up @@ -224,6 +245,7 @@ public UserDto find(
return linksInjector.injectLinks(asDto(user), getServiceContext());
}

@Deprecated
@DELETE
@Path("/{id}")
@GenerateLink(rel = LINK_REL_USER)
Expand All @@ -243,6 +265,7 @@ public void remove(@Parameter(description = "User identifier") @PathParam("id")
userManager.remove(id);
}

@Deprecated
@GET
@Path("/settings")
@Produces(APPLICATION_JSON)
Expand Down

0 comments on commit f5856a7

Please sign in to comment.