Skip to content

Commit

Permalink
Upgrade openapi swagger 3 + Fix Patch jaxrs method (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbenali authored Aug 22, 2022
1 parent 93cf26a commit a1347dd
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 366 deletions.
19 changes: 3 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<parent>
<artifactId>addons-parent-pom</artifactId>
<groupId>org.exoplatform.addons</groupId>
<version>15-M03</version>
<version>16-M04</version>
</parent>
<groupId>org.exoplatform.addons.time-tracker</groupId>
<artifactId>time-tracker</artifactId>
Expand All @@ -42,10 +42,8 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<tag>HEAD</tag>
</scm>
<properties>
<org.exoplatform.commons.version>6.3.x-SNAPSHOT</org.exoplatform.commons.version>
<org.exoplatform.social.version>6.3.x-SNAPSHOT</org.exoplatform.social.version>
<org.lombok.version>1.18.2</org.lombok.version>
<org.jackson.version>2.4.2</org.jackson.version>
<org.exoplatform.commons.version>6.4.x-SNAPSHOT</org.exoplatform.commons.version>
<org.exoplatform.social.version>6.4.x-SNAPSHOT</org.exoplatform.social.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -92,17 +90,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<scope>provided</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
<version>${org.jackson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
6 changes: 6 additions & 0 deletions time-tracker-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!--swagger-->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->

<!-- Test -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
*/
package org.exoplatform.timetracker.rest;

import io.swagger.annotations.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

import org.apache.commons.lang.StringUtils;
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.container.PortalContainer;
Expand Down Expand Up @@ -49,7 +54,7 @@
*/
@Path("timetracker/activitymgn")
@RolesAllowed("users")
@Api(value = "/timetracker", description = "Manage and access Activity center Activitys") // NOSONAR
@Tag(name = "/timetracker", description = "Manage and access Activity center Activitys") // NOSONAR
public class ActivitiesManagementREST implements ResourceContainer {

private static final Log LOG = ExoLogger.getLogger(ActivitiesManagementREST.class);
Expand Down Expand Up @@ -80,9 +85,9 @@ public ActivitiesManagementREST(ActivityService activityService, TeamService tea
@Path("activity/all")
@RolesAllowed("users")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Retrieves all available subresources of current endpoint", httpMethod = "GET", response = Response.class, produces = "application/json")
@ApiResponses(value = {@ApiResponse(code = HTTPStatus.OK, message = "Request fulfilled"),
@ApiResponse(code = 500, message = "Internal server error")})
@Operation(summary = "Retrieves all available subresources of current endpoint", method = "GET")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Request fulfilled"),
@ApiResponse(responseCode = "500", description = "Internal server error")})
public Response getAllActivities() {
try {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
Expand All @@ -105,9 +110,9 @@ public Response getAllActivities() {
@Path("activity")
@RolesAllowed("users")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Retrieves all available subresources of current endpoint", httpMethod = "GET", response = Response.class, produces = "application/json")
@ApiResponses(value = {@ApiResponse(code = HTTPStatus.OK, message = "Request fulfilled"),
@ApiResponse(code = 500, message = "Internal server error")})
@Operation(summary = "Retrieves all available subresources of current endpoint", method = "GET")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Request fulfilled"),
@ApiResponse(responseCode = "500", description = "Internal server error")})
public Response getActivities(@QueryParam("userName") String userName) {
try {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
Expand Down Expand Up @@ -142,11 +147,11 @@ public Response getActivities(@QueryParam("userName") String userName) {
@Path("activity")
@RolesAllowed("time-tracking-managers")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates a new Activity", httpMethod = "POST", response = Response.class, notes = "empty response")
@ApiResponses(value = {@ApiResponse(code = HTTPStatus.NO_CONTENT, message = "Request fulfilled"),
@ApiResponse(code = HTTPStatus.UNAUTHORIZED, message = "Unauthorized operation"),
@ApiResponse(code = 500, message = "Internal server error")})
public Response createActivity(@ApiParam(value = "Activity to save", required = true) Activity activity) {
@Operation(summary = "Creates a new Activity", method = "POST", description = "empty response")
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Request fulfilled"),
@ApiResponse(responseCode = "401", description = "Unauthorized operation"),
@ApiResponse(responseCode = "500", description = "Internal server error")})
public Response createActivity(@Parameter(description = "Activity to save", required = true) Activity activity) {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
if (sourceIdentity == null) {
return Response.status(Response.Status.UNAUTHORIZED).build();
Expand All @@ -173,11 +178,11 @@ public Response createActivity(@ApiParam(value = "Activity to save", required =
@PUT
@Path("activity")
@RolesAllowed("time-tracking-managers")
@ApiOperation(value = "Updates an existing Activity identified by its id", httpMethod = "PUT", response = Response.class, notes = "empty response")
@ApiResponses(value = {@ApiResponse(code = HTTPStatus.NO_CONTENT, message = "Request fulfilled"),
@ApiResponse(code = HTTPStatus.UNAUTHORIZED, message = "Unauthorized operation"),
@ApiResponse(code = 500, message = "Internal server error")})
public Response updateActivity(@ApiParam(value = "Activity to update", required = true) Activity activity) {
@Operation(summary = "Updates an existing Activity identified by its id", method = "PUT", description = "empty response")
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Request fulfilled"),
@ApiResponse(responseCode = "401", description = "Unauthorized operation"),
@ApiResponse(responseCode = "500", description = "Internal server error")})
public Response updateActivity(@Parameter(description = "Activity to update", required = true) Activity activity) {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
if (sourceIdentity == null) {
return Response.status(Response.Status.UNAUTHORIZED).build();
Expand Down Expand Up @@ -207,11 +212,11 @@ public Response updateActivity(@ApiParam(value = "Activity to update", required
@DELETE
@Path("activity/{activityId}")
@RolesAllowed("time-tracking-managers")
@ApiOperation(value = "Deletes an existing Activity identified by its id", httpMethod = "DELETE", response = Response.class, notes = "empty response")
@ApiResponses(value = {@ApiResponse(code = HTTPStatus.NO_CONTENT, message = "Request fulfilled"),
@ApiResponse(code = HTTPStatus.UNAUTHORIZED, message = "Unauthorized operation"),
@ApiResponse(code = 500, message = "Internal server error")})
public Response deleteActivity(@ApiParam(value = "Activity technical id to delete", required = true) @PathParam("activityId") Long activityId) {
@Operation(summary = "Deletes an existing Activity identified by its id", method = "DELETE", description = "empty response")
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Request fulfilled"),
@ApiResponse(responseCode = "401", description = "Unauthorized operation"),
@ApiResponse(responseCode = "500", description = "Internal server error")})
public Response deleteActivity(@Parameter(description = "Activity technical id to delete", required = true) @PathParam("activityId") Long activityId) {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
if (sourceIdentity == null) {
return Response.status(Response.Status.UNAUTHORIZED).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@
*/
package org.exoplatform.timetracker.rest;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import javax.annotation.security.RolesAllowed;
import javax.persistence.EntityExistsException;
Expand All @@ -39,21 +31,23 @@

import org.apache.commons.lang.StringUtils;
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.commons.utils.CommonsUtils;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.rest.resource.ResourceContainer;
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.social.core.identity.model.Identity;
import org.exoplatform.social.core.manager.IdentityManager;
import org.exoplatform.social.service.rest.Util;
import org.exoplatform.timetracker.dto.*;
import org.exoplatform.timetracker.service.ActivityRecordService;
import org.exoplatform.timetracker.service.TeamService;
import org.exoplatform.timetracker.service.TimeTrackerSettingsService;

import io.swagger.annotations.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
* <p>ActivityRecordsManagementREST class.</p>
Expand All @@ -63,7 +57,7 @@
*/
@Path("timetracker/activityRecordrecordsmgn")
@RolesAllowed("users")
@Api(value = "/timetracker", description = "Manage and access ActivityRecord center ActivityRecords") // NOSONAR
@Tag(name = "/timetracker", description = "Manage and access ActivityRecord center ActivityRecords") // NOSONAR
public class ActivityRecordsManagementREST implements ResourceContainer {

private static final Log LOG = ExoLogger.getLogger(ActivityRecordsManagementREST.class);
Expand Down Expand Up @@ -100,9 +94,9 @@ public ActivityRecordsManagementREST(ActivityRecordService activityRecordService
@Path("activityrecord")
@RolesAllowed("users")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Retrieves all available subresources of current endpoint", httpMethod = "GET", response = Response.class, produces = "application/json")
@ApiResponses(value = { @ApiResponse(code = HTTPStatus.OK, message = "Request fulfilled"),
@ApiResponse(code = 500, message = "Internal server error") })
@Operation(summary = "Retrieves all available subresources of current endpoint", method = "GET")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Request fulfilled"),
@ApiResponse(responseCode = "500", description = "Internal server error") })
public Response getActivityRecords() {
try {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
Expand Down Expand Up @@ -143,9 +137,9 @@ public Response getActivityRecords() {
@Path("activityrecord/list")
@RolesAllowed("users")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Retrieves all available subresources of current endpoint", httpMethod = "GET", response = Response.class, produces = "application/json")
@ApiResponses(value = { @ApiResponse(code = HTTPStatus.OK, message = "Request fulfilled"),
@ApiResponse(code = 500, message = "Internal server error") })
@Operation(summary = "Retrieves all available subresources of current endpoint", method = "GET")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Request fulfilled"),
@ApiResponse(responseCode = "500", description = "Internal server error") })
public Response getActivityRecordsList(@Context UriInfo uriInfo,
@QueryParam("search") String search,
@QueryParam("activity") String activity,
Expand Down Expand Up @@ -204,9 +198,9 @@ public Response getActivityRecordsList(@Context UriInfo uriInfo,
@Path("activityrecord/last")
@RolesAllowed("users")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Retrieves all available subresources of current endpoint", httpMethod = "GET", response = Response.class, produces = "application/json")
@ApiResponses(value = { @ApiResponse(code = HTTPStatus.OK, message = "Request fulfilled"),
@ApiResponse(code = 500, message = "Internal server error") })
@Operation(summary = "Retrieves all available subresources of current endpoint", method = "GET")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Request fulfilled"),
@ApiResponse(responseCode = "500", description = "Internal server error") })
public Response getActivityRecordsList(@Context UriInfo uriInfo,
@QueryParam("userName") String userName) {
try {
Expand Down Expand Up @@ -234,9 +228,9 @@ public Response getActivityRecordsList(@Context UriInfo uriInfo,
@Path("activityrecord/{day}")
@RolesAllowed("users")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Retrieves all available subresources of current endpoint", httpMethod = "GET", response = Response.class, produces = "application/json")
@ApiResponses(value = { @ApiResponse(code = HTTPStatus.OK, message = "Request fulfilled"),
@ApiResponse(code = 500, message = "Internal server error") })
@Operation(summary = "Retrieves all available subresources of current endpoint", method = "GET")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Request fulfilled"),
@ApiResponse(responseCode = "500", description = "Internal server error") })
public Response getActivityRecords(@PathParam("day") String day) {
try {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
Expand All @@ -260,11 +254,11 @@ public Response getActivityRecords(@PathParam("day") String day) {
@Path("activityrecord")
@RolesAllowed("users")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates a new ActivityRecord", httpMethod = "POST", response = Response.class, notes = "empty response")
@ApiResponses(value = { @ApiResponse(code = HTTPStatus.NO_CONTENT, message = "Request fulfilled"),
@ApiResponse(code = HTTPStatus.UNAUTHORIZED, message = "Unauthorized operation"),
@ApiResponse(code = 500, message = "Internal server error") })
public Response createActivityRecord(@ApiParam(value = "ActivityRecord to save", required = true) ActivityRecord activityRecord) {
@Operation(summary = "Creates a new ActivityRecord", method = "POST", description = "empty response")
@ApiResponses(value = { @ApiResponse(responseCode = "204", description = "Request fulfilled"),
@ApiResponse(responseCode = "401", description = "Unauthorized operation"),
@ApiResponse(responseCode = "500", description = "Internal server error") })
public Response createActivityRecord(@Parameter(description = "ActivityRecord to save", required = true) ActivityRecord activityRecord) {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
if (sourceIdentity == null) {
return Response.status(Response.Status.UNAUTHORIZED).build();
Expand Down Expand Up @@ -297,11 +291,11 @@ public Response createActivityRecord(@ApiParam(value = "ActivityRecord to save",
@PUT
@Path("activityrecord")
@RolesAllowed("users")
@ApiOperation(value = "Updates an existing ActivityRecord identified by its id", httpMethod = "PUT", response = Response.class, notes = "empty response")
@ApiResponses(value = { @ApiResponse(code = HTTPStatus.NO_CONTENT, message = "Request fulfilled"),
@ApiResponse(code = HTTPStatus.UNAUTHORIZED, message = "Unauthorized operation"),
@ApiResponse(code = 500, message = "Internal server error") })
public Response updateActivityRecord(@ApiParam(value = "ActivityRecord to update", required = true) ActivityRecord activityRecord) {
@Operation(summary = "Updates an existing ActivityRecord identified by its id", method = "PUT", description = "empty response")
@ApiResponses(value = { @ApiResponse(responseCode = "204", description = "Request fulfilled"),
@ApiResponse(responseCode = "401", description = "Unauthorized operation"),
@ApiResponse(responseCode = "500", description = "Internal server error") })
public Response updateActivityRecord(@Parameter(description = "ActivityRecord to update", required = true) ActivityRecord activityRecord) {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
if (sourceIdentity == null) {
return Response.status(Response.Status.UNAUTHORIZED).build();
Expand Down Expand Up @@ -331,11 +325,11 @@ public Response updateActivityRecord(@ApiParam(value = "ActivityRecord to update
@DELETE
@Path("activityrecord/{activityrecordId}")
@RolesAllowed("users")
@ApiOperation(value = "Deletes an existing ActivityRecord identified by its id", httpMethod = "DELETE", response = Response.class, notes = "empty response")
@ApiResponses(value = { @ApiResponse(code = HTTPStatus.NO_CONTENT, message = "Request fulfilled"),
@ApiResponse(code = HTTPStatus.UNAUTHORIZED, message = "Unauthorized operation"),
@ApiResponse(code = 500, message = "Internal server error") })
public Response deleteActivityRecord(@ApiParam(value = "ActivityRecord technical id to delete", required = true) @PathParam("activityrecordId") Long activityRecordId) {
@Operation(summary = "Deletes an existing ActivityRecord identified by its id", method = "DELETE", description = "empty response")
@ApiResponses(value = { @ApiResponse(responseCode = "204", description = "Request fulfilled"),
@ApiResponse(responseCode = "401", description = "Unauthorized operation"),
@ApiResponse(responseCode = "500", description = "Internal server error") })
public Response deleteActivityRecord(@Parameter(description = "ActivityRecord technical id to delete", required = true) @PathParam("activityrecordId") Long activityRecordId) {
Identity sourceIdentity = Util.getAuthenticatedUserIdentity(portalContainerName);
if (sourceIdentity == null) {
return Response.status(Response.Status.UNAUTHORIZED).build();
Expand Down
Loading

0 comments on commit a1347dd

Please # to comment.