From 9ecffda0c1bf186e308578216cb478ad3665df06 Mon Sep 17 00:00:00 2001 From: Moritzjenny <moritzjenny@hotmail.com> Date: Wed, 11 Sep 2019 13:59:49 +0200 Subject: [PATCH] OO-4096: Rest Documentation Server prefix --- .../calendar/restapi/CalWebService.java | 51 +-- .../restapi/UserCalendarWebService.java | 11 +- .../info/restapi/InfoMessageWebService.java | 18 + .../info/restapi/InfoMessagesWebService.java | 29 +- .../restapi/NotificationsWebService.java | 64 ++- .../services/vfs/restapi/VFSWebservice.java | 98 ++++- .../course/db/restapi/CourseDbWebService.java | 111 +++++- .../olat/course/nodes/bc/BCWebService.java | 88 ++++- .../olat/course/nodes/co/COWebService.java | 45 ++- .../olat/course/nodes/en/ENWebService.java | 57 ++- .../CurriculumElementTypesWebService.java | 95 ++++- .../restapi/CurriculumElementsWebService.java | 374 +++++++++++++++++- .../restapi/CurriculumsWebService.java | 99 ++++- .../restapi/DocumentPoolModuleWebService.java | 17 + .../fo/restapi/ForumCourseNodeWebService.java | 68 ++++ .../modules/fo/restapi/ForumWebService.java | 128 +++++- .../fo/restapi/MyForumsWebService.java | 21 + .../group/LearningGroupWebService.java | 1 + .../RepositoryEntriesWebService.java | 3 +- .../course/CourseAssessmentWebService.java | 4 + 20 files changed, 1305 insertions(+), 77 deletions(-) diff --git a/src/main/java/org/olat/commons/calendar/restapi/CalWebService.java b/src/main/java/org/olat/commons/calendar/restapi/CalWebService.java index a03dc00e16c..82d97edc593 100644 --- a/src/main/java/org/olat/commons/calendar/restapi/CalWebService.java +++ b/src/main/java/org/olat/commons/calendar/restapi/CalWebService.java @@ -59,6 +59,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.ArraySchema; + import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -84,18 +86,18 @@ public class CalWebService { @Path("events") @Operation(summary = "List events from a calendar.", description = "Returns list of events from a specific calendar.") @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Request was successful.", + @ApiResponse(responseCode = "200", description = "Request was successful", content = { - @Content(mediaType = "application/json", schema = @Schema(implementation = EventVO.class)), - @Content(mediaType = "application/xml", schema = @Schema(implementation = EventVO.class)) + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = EventVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = EventVO.class))) } ), - @ApiResponse(responseCode = "401", description = "Not authorized."), - @ApiResponse(responseCode = "404", description = "Not found.")} + @ApiResponse(responseCode = "401", description = "Not authorized"), + @ApiResponse(responseCode = "404", description = "Not found")} ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response getEventsByCalendar(@QueryParam("start")@Parameter(description = "Set the date for the earliest event.") @DefaultValue("0") Integer start, - @QueryParam("limit") @Parameter(description = "Limit the amount of events to be returned.") @DefaultValue("25") Integer limit, + public Response getEventsByCalendar(@QueryParam("start")@Parameter(description = "Set the date for the earliest event") @DefaultValue("0") Integer start, + @QueryParam("limit") @Parameter(description = "Limit the amount of events to be returned") @DefaultValue("25") Integer limit, @QueryParam("onlyFuture") @DefaultValue("false") Boolean onlyFuture, @Context HttpServletRequest httpRequest, @Context Request request) { @@ -158,14 +160,9 @@ public class CalWebService { @Path("event") @Operation(summary = "Put a specific event.", description = "Puts a specific event in a specific calendar.") @ApiResponses(value = { - @ApiResponse(responseCode = "200", - content = { - @Content(mediaType = "application/json", schema = @Schema(implementation = EventVO.class)), - @Content(mediaType = "application/xml", schema = @Schema(implementation = EventVO.class)) - } - ), - @ApiResponse(responseCode = "401", description = "Not authorized."), - @ApiResponse(responseCode = "404", description = "Not found.")} + @ApiResponse(responseCode = "200",description = "Ok"), + @ApiResponse(responseCode = "401", description = "Not authorized"), + @ApiResponse(responseCode = "404", description = "Not found")} ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @@ -178,13 +175,9 @@ public class CalWebService { @Path("events") @Operation(summary = "Put specific events.", description = "Puts specific events in a specific calendar.") @ApiResponses(value = { - @ApiResponse(responseCode = "200", - content = { - @Content(mediaType = "application/json", schema = @Schema(implementation = EventVO[].class)), - @Content(mediaType = "application/xml", schema = @Schema(implementation = EventVO[].class)) - } + @ApiResponse(responseCode = "200", description = "Ok" ), - @ApiResponse(responseCode = "401", description = "Not authorized."), + @ApiResponse(responseCode = "401", description = "Not authorized"), @ApiResponse(responseCode = "404", description = "Not found.")} ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @@ -201,14 +194,10 @@ public class CalWebService { @Path("event") @Operation(summary = "Post a specific event.", description = "Posts a specific event in a specific calendar.") @ApiResponses(value = { - @ApiResponse(responseCode = "200", - content = { - @Content(mediaType = "application/json", schema = @Schema(implementation = EventVO.class)), - @Content(mediaType = "application/xml", schema = @Schema(implementation = EventVO.class)) - } + @ApiResponse(responseCode = "200", description = "Ok" ), - @ApiResponse(responseCode = "401", description = "Not authorized."), - @ApiResponse(responseCode = "404", description = "Not found.")} + @ApiResponse(responseCode = "401", description = "Not authorized"), + @ApiResponse(responseCode = "404", description = "Not found")} ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @@ -221,11 +210,7 @@ public class CalWebService { @Path("events") @Operation(summary = "Post specific events.", description = "Posts specific events in a specific calendar.") @ApiResponses(value = { - @ApiResponse(responseCode = "200", - content = { - @Content(mediaType = "application/json", schema = @Schema(implementation = EventVO[].class)), - @Content(mediaType = "application/xml", schema = @Schema(implementation = EventVO[].class)) - } + @ApiResponse(responseCode = "200", description = "Ok." ), @ApiResponse(responseCode = "401", description = "Not authorized."), @ApiResponse(responseCode = "404", description = "Not found.")} diff --git a/src/main/java/org/olat/commons/calendar/restapi/UserCalendarWebService.java b/src/main/java/org/olat/commons/calendar/restapi/UserCalendarWebService.java index b1e2b9220bb..2f78e35be16 100644 --- a/src/main/java/org/olat/commons/calendar/restapi/UserCalendarWebService.java +++ b/src/main/java/org/olat/commons/calendar/restapi/UserCalendarWebService.java @@ -88,6 +88,7 @@ import io.swagger.v3.oas.annotations.media.Schema; 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 io.swagger.v3.oas.annotations.media.ArraySchema; /** * @@ -120,8 +121,8 @@ public class UserCalendarWebService { @ApiResponses({ @ApiResponse(responseCode = "200", description = "Request was successful.", content = { - @Content(mediaType = "application/json", schema = @Schema(implementation = CalendarVO.class)), - @Content(mediaType = "application/xml", schema = @Schema(implementation = CalendarVO.class)) + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = CalendarVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = CalendarVO.class))) }, links = {}), @ApiResponse(responseCode = "401", description = "Not authorized."), @ApiResponse(responseCode = "404", description = "Not found.")} @@ -173,12 +174,12 @@ public class UserCalendarWebService { @GET @Path("events") - @Operation(summary = "List all events.", description = "Returns list of all events in for a specific user.") + @Operation(summary = "List all events from a user.", description = "Returns list of all events in for a specific user.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "Request was successful.", content = { - @Content(mediaType = "application/json", schema = @Schema(implementation = EventVO[].class)), - @Content(mediaType = "application/xml", schema = @Schema(implementation = EventVO[].class)) + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = EventVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = EventVO.class))) } ), @ApiResponse(responseCode = "401", description = "Not authorized."), diff --git a/src/main/java/org/olat/commons/info/restapi/InfoMessageWebService.java b/src/main/java/org/olat/commons/info/restapi/InfoMessageWebService.java index cf5907017c4..5f9303d1b9f 100644 --- a/src/main/java/org/olat/commons/info/restapi/InfoMessageWebService.java +++ b/src/main/java/org/olat/commons/info/restapi/InfoMessageWebService.java @@ -29,6 +29,12 @@ import javax.ws.rs.core.Response; import org.olat.commons.info.InfoMessage; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + /** * * Description:<br> @@ -58,6 +64,18 @@ public class InfoMessageWebService { * @return It returns the newly info message */ @GET + @Operation(summary = "Get an new info message by key", + description = "Get an new info message by key") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The info message", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = InfoMessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = InfoMessageVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "Not Found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getMessage(@Context HttpServletRequest request) { InfoMessageVO msgVO = new InfoMessageVO(msg); diff --git a/src/main/java/org/olat/commons/info/restapi/InfoMessagesWebService.java b/src/main/java/org/olat/commons/info/restapi/InfoMessagesWebService.java index 6d2cd4639a1..42ae6b276f1 100644 --- a/src/main/java/org/olat/commons/info/restapi/InfoMessagesWebService.java +++ b/src/main/java/org/olat/commons/info/restapi/InfoMessagesWebService.java @@ -48,6 +48,12 @@ import org.olat.core.util.resource.OresHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -79,6 +85,9 @@ public class InfoMessagesWebService { */ @GET @Path("version") + @Operation(summary = "The version of the Info messages Web Service", + description = "The version of the Info messages Web Service") + @ApiResponse(responseCode = "200", description = "The version of this specific Web Service") @Produces(MediaType.TEXT_PLAIN) public Response getVersion() { return Response.ok(VERSION).build(); @@ -102,11 +111,23 @@ public class InfoMessagesWebService { * @return It returns the id of the newly info message */ @PUT + @Operation(summary = "Creates a new info message", + description = "Creates a new info message") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The info message", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = InfoMessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = InfoMessageVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "Not Found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response createEmptyCourse(final @QueryParam("resName") String resName, - final @QueryParam("resId") Long resId, @QueryParam("resSubPath") String resSubPath, - @QueryParam("businessPath") String businessPath, @QueryParam("authorKey") Long authorKey, - @QueryParam("title") String title, @QueryParam("message") String message, + public Response createEmptyCourse(final @QueryParam("resName") @Parameter(description = "The OLAT Resourceable name") String resName, + final @QueryParam("resId") @Parameter(description = "The OLAT Resourceable id") Long resId, @QueryParam("resSubPath") @Parameter(description = "The resource sub path (optional)") String resSubPath, + @QueryParam("businessPath") @Parameter(description = "The business path") String businessPath, @QueryParam("authorKey") @Parameter(description = "The identity key of the author") Long authorKey, + @QueryParam("title") @Parameter(description = "The title") String title, @QueryParam("message") @Parameter(description = "The message") String message, @Context HttpServletRequest request) { if(!isAuthor(request)) { diff --git a/src/main/java/org/olat/core/commons/services/notifications/restapi/NotificationsWebService.java b/src/main/java/org/olat/core/commons/services/notifications/restapi/NotificationsWebService.java index 5d43251181b..8a8e059a4b9 100644 --- a/src/main/java/org/olat/core/commons/services/notifications/restapi/NotificationsWebService.java +++ b/src/main/java/org/olat/core/commons/services/notifications/restapi/NotificationsWebService.java @@ -24,6 +24,7 @@ package org.olat.core.commons.services.notifications.restapi; import static org.olat.restapi.security.RestSecurityHelper.parseDate; + import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -62,11 +63,20 @@ import org.olat.core.id.Roles; import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.ContextEntry; import org.olat.core.util.StringHelper; +import org.olat.modules.fo.restapi.MessageVO; import org.olat.restapi.security.RestSecurityHelper; import org.olat.user.restapi.UserVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + /** * * <h3>Description:</h3> @@ -98,6 +108,18 @@ public class NotificationsWebService { */ @GET @Path("publisher/{ressourceName}/{ressourceId}/{subIdentifier}") + @Operation(summary = "Get publisher", + description = "Get the publisher by resource name and id + sub identifier") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The publisher", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = PublisherVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = PublisherVO.class)) + } + ), + @ApiResponse(responseCode = "204", description = "The publisher doesn't exist"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient")} + ) @Produces({MediaType.APPLICATION_XML ,MediaType.APPLICATION_JSON}) public Response getPublisher(@PathParam("ressourceName") String ressourceName, @PathParam("ressourceId") Long ressourceId, @PathParam("subIdentifier") String subIdentifier, @Context HttpServletRequest request) { @@ -118,6 +140,19 @@ public class NotificationsWebService { @GET @Path("subscribers/{ressourceName}/{ressourceId}/{subIdentifier}") + @Operation(summary = "Get subscribers", + description = "Get the subscribers by resource name and id + sub identifier") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The subscribers", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = SubscriberVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = SubscriberVO.class))) + } + ), + @ApiResponse(responseCode = "204", description = "The subscribers don't exist"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient")} + ) + @Produces({MediaType.APPLICATION_XML ,MediaType.APPLICATION_JSON}) public Response getSubscriber(@PathParam("ressourceName") String ressourceName, @PathParam("ressourceId") Long ressourceId, @PathParam("subIdentifier") String subIdentifier, @Context HttpServletRequest request) { @@ -148,6 +183,13 @@ public class NotificationsWebService { @PUT @Path("subscribers") + @Operation(summary = "Put subscribers", + description = "Put the subscribers") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The author or message not found")} + ) @Consumes({MediaType.APPLICATION_XML ,MediaType.APPLICATION_JSON}) public Response subscribe(PublisherVO publisherVO, @Context HttpServletRequest request) { if(!isAdmin(request)) { @@ -171,6 +213,13 @@ public class NotificationsWebService { @DELETE @Path("subscribers/{subscriberKey}") + @Operation(summary = "Delete subscribers", + description = "Delete the subscribers by id") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The author or message not found")} + ) @Consumes({MediaType.APPLICATION_XML ,MediaType.APPLICATION_JSON}) public Response unsubscribe(@PathParam("subscriberKey") Long subscriberKey, @Context HttpServletRequest request) { if(!isAdmin(request)) { @@ -196,9 +245,20 @@ public class NotificationsWebService { * correspond to a <code>SubscriptionInfoVO</code>. <code>SubscriptionInfoVO</code> */ @GET + @Operation(summary = "Retrieves the notification of the logged in user", + description = "Retrieves the notification of the logged in user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok.", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = MessageVO.class)) + } + ), + @ApiResponse(responseCode = "404", description = "The identity not found")} + ) @Produces({MediaType.APPLICATION_XML ,MediaType.APPLICATION_JSON}) - public Response getNotifications(@QueryParam("date") String date, - @QueryParam("type") String type, @Context HttpServletRequest httpRequest) { + public Response getNotifications(@QueryParam("date") @Parameter(description = "The date (optional)") String date, + @QueryParam("type") @Parameter(description = "The type of notifications (User, Forum...) (optional)") String type, @Context HttpServletRequest httpRequest) { Identity identity = RestSecurityHelper.getIdentity(httpRequest); Locale locale = RestSecurityHelper.getLocale(httpRequest); diff --git a/src/main/java/org/olat/core/commons/services/vfs/restapi/VFSWebservice.java b/src/main/java/org/olat/core/commons/services/vfs/restapi/VFSWebservice.java index c6f848a6826..703b7aee10a 100644 --- a/src/main/java/org/olat/core/commons/services/vfs/restapi/VFSWebservice.java +++ b/src/main/java/org/olat/core/commons/services/vfs/restapi/VFSWebservice.java @@ -68,6 +68,14 @@ import org.olat.restapi.support.MultipartReader; import org.olat.restapi.support.vo.File64VO; import org.olat.restapi.support.vo.FileMetadataVO; import org.olat.restapi.support.vo.FileVO; +import org.olat.restapi.support.vo.LinkVO; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; public class VFSWebservice { @@ -96,6 +104,9 @@ public class VFSWebservice { */ @GET @Path("version") + @Operation(summary = "Retrieve version", + description = "Retrieves the version of the Folder Course Node Web Service") + @ApiResponse(responseCode = "200", description = "The version of this specific Web Service") @Produces(MediaType.TEXT_PLAIN) public Response getVersion() { return Response.ok(VERSION).build(); @@ -110,6 +121,12 @@ public class VFSWebservice { * @return */ @GET + @Operation(summary = "Retrieve files", + description = "This retrieves the files or a specific file in the root folder") + @ApiResponse(responseCode = "200", description = "The list of files", content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = LinkVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = LinkVO.class))) + } ) @Produces({"*/*", MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML, MediaType.APPLICATION_OCTET_STREAM}) public Response listFiles(@Context UriInfo uriInfo, @Context Request request) { return get(Collections.<PathSegment>emptyList(), uriInfo, request); @@ -126,6 +143,12 @@ public class VFSWebservice { */ @GET @Path("{path:.*}") + @Operation(summary = "Retrieve files", + description = "This retrieves the files or a specific file in a folder") + @ApiResponse(responseCode = "200", description = "The list of files or the file", content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = LinkVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = LinkVO.class))) + } ) @Produces({"*/*", MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML, MediaType.APPLICATION_OCTET_STREAM}) public Response listFiles(@PathParam("path") List<PathSegment> path, @Context UriInfo uriInfo, @Context Request request) { return get(path, uriInfo, request); @@ -143,8 +166,15 @@ public class VFSWebservice { */ @GET @Path("metadata/{path:.*}") + @Operation(summary = "Retrieve metadata", + description = "This retrieves some metadata of a specific file in a folder.\n" + + " The metadata are: filename, size, date of last modification, MIME-type and file href for downloading via REST") + @ApiResponse(responseCode = "200", description = "The list of files or the file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = FileMetadataVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = FileMetadataVO.class)) + } ) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public Response getFileMetadata(@PathParam("path") List<PathSegment> path, @Context UriInfo uriInfo) { + public Response getFileMetadata(@PathParam("path") @Parameter(description = "the path to the file List<PathSegment>") List<PathSegment> path, @Context UriInfo uriInfo) { return getFMetadata(path, uriInfo); } @@ -160,6 +190,13 @@ public class VFSWebservice { * @return The link to the created file */ @POST + @Operation(summary = "Upload a file", + description = "Upload a file to the root folder or create a new folder. One of the two sets\n" + + " of parameters must be set: foldername to create") + @ApiResponse(responseCode = "200", description = "The link to the created file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response postFileToRoot(@Context UriInfo uriInfo, @Context HttpServletRequest request) { @@ -178,10 +215,17 @@ public class VFSWebservice { * @return The link to the created file */ @POST + @Operation(summary = "Upload a file", + description = "Upload a file to the root folder or create a new folder. One of the two sets\n" + + "of parameters must be set: foldername to create") + @ApiResponse(responseCode = "200", description = "The link to the created file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public Response postFile64ToRoot(@FormParam("foldername") String foldername, @FormParam("filename") String filename, - @FormParam("file") String file, @Context UriInfo uriInfo) { + public Response postFile64ToRoot(@FormParam("foldername")String foldername, @FormParam("filename") String filename, + @FormParam("file")String file, @Context UriInfo uriInfo) { byte[] fileAsBytes = Base64.decodeBase64(file); try(InputStream in = new ByteArrayInputStream(fileAsBytes)) { return putFile(foldername, filename, in, uriInfo, Collections.<PathSegment>emptyList()); @@ -205,6 +249,12 @@ public class VFSWebservice { */ @POST @Path("{path:.*}") + @Operation(summary = "Upload a file", + description = "Upload a file to the specified folder or create a new folder") + @ApiResponse(responseCode = "200", description = "The link to the created file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces({"*/*", MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response postFileToFolder(@Context UriInfo uriInfo, @PathParam("path") List<PathSegment> path, @@ -225,6 +275,12 @@ public class VFSWebservice { */ @POST @Path("{path:.*}") + @Operation(summary = "Upload a file", + description = "Upload a file to the specified folder or create a new folder") + @ApiResponse(responseCode = "200", description = "The link to the created file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({"*/*", MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response postFile64ToFolder(@FormParam("foldername") String foldername, @FormParam("filename") String filename, @@ -250,6 +306,12 @@ public class VFSWebservice { * @return The link to the created file */ @PUT + @Operation(summary = "Upload a file", + description = "Upload a file to the specified folder or create a new folder") + @ApiResponse(responseCode = "200", description = "The link to the created file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response putFileToRoot(@Context UriInfo uriInfo, @Context HttpServletRequest request) { @@ -267,6 +329,12 @@ public class VFSWebservice { * @return The link to the created file */ @PUT + @Operation(summary = "Upload a file", + description = "Upload a file to the specified folder or create a new folder") + @ApiResponse(responseCode = "200", description = "The link to the created file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response putFile64VOToRoot(File64VO file, @Context UriInfo uriInfo) { @@ -292,6 +360,12 @@ public class VFSWebservice { * @return The link to the created file */ @PUT + @Operation(summary = "Upload a file", + description = "Upload a file to the specified folder or create a new folder") + @ApiResponse(responseCode = "200", description = "The link to the created file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Path("{path:.*}") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces({"*/*", MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @@ -338,6 +412,12 @@ public class VFSWebservice { */ @PUT @Path("{path:.*}") + @Operation(summary = "Upload a file", + description = "Upload a file to the specified folder or create a new folder") + @ApiResponse(responseCode = "200", description = "The link to the created file", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response putFile64ToFolder(File64VO file, @Context UriInfo uriInfo, @PathParam("path") List<PathSegment> path) { @@ -361,6 +441,12 @@ public class VFSWebservice { */ @PUT @Path("{path:.*}") + @Operation(summary = "Create folders", + description = "Create fodlers") + @ApiResponse(responseCode = "200", description = "The link to the created folder", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response putFolders(@Context UriInfo uriInfo, @PathParam("path") List<PathSegment> path) { @@ -369,6 +455,12 @@ public class VFSWebservice { @DELETE @Path("{path:.*}") + @Operation(summary = "Delete folders", + description = "Delete") + @ApiResponse(responseCode = "200", description = "Ok", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = LinkVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = LinkVO.class)) + } ) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response deleteItem(@PathParam("path") List<PathSegment> path) { if(container.getLocalSecurityCallback() != null && !container.getLocalSecurityCallback().canDelete()) { diff --git a/src/main/java/org/olat/course/db/restapi/CourseDbWebService.java b/src/main/java/org/olat/course/db/restapi/CourseDbWebService.java index 3ad4ae0287f..2a9dfeed1c3 100644 --- a/src/main/java/org/olat/course/db/restapi/CourseDbWebService.java +++ b/src/main/java/org/olat/course/db/restapi/CourseDbWebService.java @@ -22,6 +22,7 @@ package org.olat.course.db.restapi; import java.util.List; + import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -37,7 +38,6 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; - import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.id.Identity; @@ -54,6 +54,12 @@ import org.olat.restapi.support.vo.KeyValuePair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -83,6 +89,9 @@ public class CourseDbWebService { */ @GET @Path("version") + @Operation(summary = "Retrieve version", + description = "Retrieves the version of the Course DB Web Service") + @ApiResponse(responseCode = "200", description = "The version of this specific Web Service") @Produces(MediaType.TEXT_PLAIN) public Response getVersion() { return Response.ok(VERSION).build(); @@ -101,6 +110,16 @@ public class CourseDbWebService { */ @GET @Path("values") + @Operation(summary = "Retrieve all values of the authenticated user", + description = "Retrieve all values of the authenticated user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "All the values in the course", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))) + } + )} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getValues(@PathParam("courseId") Long courseId, @PathParam("category") String category, @Context HttpServletRequest request) { ICourse course = loadCourse(courseId); @@ -132,6 +151,16 @@ public class CourseDbWebService { */ @PUT @Path("values") + @Operation(summary = "Put a new value for an authenticated user", + description = "Put a new value for an authenticated user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "the key value pair is saved on the db", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))) + } + )} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putValues(@PathParam("courseId") Long courseId, @PathParam("category") String category, KeyValuePair pair, @Context HttpServletRequest request) { return internPutValues(courseId, category, pair, request); @@ -152,6 +181,16 @@ public class CourseDbWebService { */ @POST @Path("values") + @Operation(summary = "Update a value for an authenticated user", + description = "Update a value for an authenticated user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "the key value pair is saved on the db", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))) + } + )} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response postValues(@PathParam("courseId") Long courseId, @PathParam("category") String category, KeyValuePair pair, @Context HttpServletRequest request) { return internPutValues(courseId, category, pair, request); @@ -172,6 +211,20 @@ public class CourseDbWebService { */ @GET @Path("values/{name}") + @Operation(summary = "Retrieve a value of an authenticated user", + description = "Retrieve a value of an authenticated user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The value in the course", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))) + } + ), + @ApiResponse(responseCode = "204", description = "The entry cannot be found" + + ) + } + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getValue(@PathParam("courseId") Long courseId, @PathParam("category") String category, @PathParam("name") String name, @Context HttpServletRequest request) { ICourse course = loadCourse(courseId); @@ -201,6 +254,20 @@ public class CourseDbWebService { */ @GET @Path("values/{name}") + @Operation(summary = "Retrieve a value of an authenticated user", + description = "Retrieve a value of an authenticated user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The value in the course", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = KeyValuePair.class))) + } + ), + @ApiResponse(responseCode = "404", description = "The entry cannot be found" + + ) + } + ) @Produces({MediaType.TEXT_PLAIN, MediaType.TEXT_HTML}) public Response getValuePlain(@PathParam("courseId") Long courseId, @PathParam("category") String category, @PathParam("name") String name, @Context HttpServletRequest request) { @@ -228,6 +295,12 @@ public class CourseDbWebService { */ @PUT @Path("values/{name}") + @Operation(summary = "Put a new value for an authenticated user", + description = "Put a new value for an authenticated user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The value is saved in the course") + } + ) public Response putValue(@PathParam("courseId") Long courseId, @PathParam("category") String category, @PathParam("name") String name, @QueryParam("value") String value, @Context HttpServletRequest request) { return internPutValue(courseId, category, name, value, request); @@ -245,6 +318,12 @@ public class CourseDbWebService { */ @POST @Path("values/{name}") + @Operation(summary = "Update a value for an authenticated user", + description = "Update a value for an authenticated user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The value is saved in the course") + } + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response formValue(@PathParam("courseId") Long courseId, @PathParam("category") String category, @PathParam("name") String name, @FormParam("val") String value, @Context HttpServletRequest request){ @@ -264,6 +343,20 @@ public class CourseDbWebService { */ @DELETE @Path("values/{name}") + @Operation(summary = "Delete a value for an authenticated user", + description = "Delete a value for an authenticated user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "the key value pair is remove from the db" + + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient" + + ), + @ApiResponse(responseCode = "404", description = "The entry cannot be found" + + ) + } + ) public Response deleteValue(@PathParam("courseId") Long courseId, @PathParam("category") String category, @PathParam("name") String name, @Context HttpServletRequest request) { UserRequest ureq = RestSecurityHelper.getUserRequest(request); @@ -280,7 +373,7 @@ public class CourseDbWebService { } /** - * Fallbakc method for the browsers + * Fallback method for the browsers * * @response.representation.200.doc the key value pair is remove from the db * @response.representation.401.doc The roles of the authenticated user are not sufficient @@ -293,6 +386,20 @@ public class CourseDbWebService { */ @POST @Path("values/{name}/delete") + @Operation(summary = "Fallback method for the browsers", + description = "Fallbakc method for the browsers") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "the key value pair is remove from the db" + + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient" + + ), + @ApiResponse(responseCode = "404", description = "The entry cannot be found" + + ) + } + ) public Response deleteValuePost(@PathParam("courseId") Long courseId, @PathParam("category") String category, @PathParam("name") String name, @Context HttpServletRequest request) { return deleteValue(courseId, category, name, request); diff --git a/src/main/java/org/olat/course/nodes/bc/BCWebService.java b/src/main/java/org/olat/course/nodes/bc/BCWebService.java index ca9f02efe88..82d8c49fa00 100644 --- a/src/main/java/org/olat/course/nodes/bc/BCWebService.java +++ b/src/main/java/org/olat/course/nodes/bc/BCWebService.java @@ -75,10 +75,19 @@ import org.olat.resource.accesscontrol.AccessResult; import org.olat.restapi.repository.course.AbstractCourseNodeWebService; import org.olat.restapi.repository.course.CourseWebService; import org.olat.restapi.repository.course.CoursesWebService; +import org.olat.restapi.support.vo.CourseNodeVO; import org.olat.restapi.support.vo.FolderVO; import org.olat.restapi.support.vo.FolderVOes; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + /** * * Description:<br> @@ -107,6 +116,18 @@ public class BCWebService extends AbstractCourseNodeWebService { * @return The persisted structure element (fully populated) */ @GET + @Operation(summary = "Retrieve metadata", + description = "Retrieves metadata of the course node") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = FolderVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = FolderVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "TThe roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getFolders(@PathParam("courseId") Long courseId, @Context HttpServletRequest httpRequest) { final ICourse course = CoursesWebService.loadCourse(courseId); @@ -178,13 +199,26 @@ public class BCWebService extends AbstractCourseNodeWebService { * @return The persisted folder element (fully populated) */ @PUT + @Operation(summary = "attach a Folder Element onto course", + description = "This attaches a Folder Element onto a given course. The element will be\n" + + " inserted underneath the supplied parentNodeId") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response attachFolder(@PathParam("courseId") Long courseId, @QueryParam("parentNodeId") String parentNodeId, - @QueryParam("position") Integer position, @QueryParam("shortTitle") @DefaultValue("undefined") String shortTitle, - @QueryParam("longTitle") @DefaultValue("undefined") String longTitle, @QueryParam("objectives") @DefaultValue("undefined") String objectives, - @QueryParam("visibilityExpertRules") String visibilityExpertRules, @QueryParam("downloadExpertRules") String downloadExpertRules, - @QueryParam("uploadExpertRules") String uploadExpertRules, @Context HttpServletRequest request) { + public Response attachFolder(@PathParam("courseId") Long courseId, @QueryParam("parentNodeId") @Parameter(description = "The node's id which will be the parent of this folder") String parentNodeId, + @QueryParam("position") @Parameter(description = "The node's position relative to its sibling nodes (optional)") Integer position, @QueryParam("shortTitle") @Parameter(description = "The node short title") @DefaultValue("undefined") String shortTitle, + @QueryParam("longTitle") @Parameter(description = "The node long title") @DefaultValue("undefined") String longTitle, @QueryParam("objectives") @Parameter(description = "The node learning objectives") @DefaultValue("undefined") String objectives, + @QueryParam("visibilityExpertRules") @Parameter(description = "The rules to view the node (optional)") String visibilityExpertRules, @QueryParam("downloadExpertRules") @Parameter(description = "The rules to download files (optional)") String downloadExpertRules, + @QueryParam("uploadExpertRules") @Parameter(description = "The rules to upload files (optional)") String uploadExpertRules, @Context HttpServletRequest request) { FolderCustomConfig config = new FolderCustomConfig(downloadExpertRules, uploadExpertRules); return attach(courseId, parentNodeId, "bc", position, shortTitle, longTitle, objectives, visibilityExpertRules, null, config, request); @@ -213,6 +247,19 @@ public class BCWebService extends AbstractCourseNodeWebService { * @return The persisted folder element (fully populated) */ @POST + @Operation(summary = "attach a Folder Element onto course", + description = "This attaches a Folder Element onto a given course. The element will be\n" + + " inserted underneath the supplied parentNodeId") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The folder node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response attachFolderPost(@PathParam("courseId") Long courseId, @FormParam("parentNodeId") String parentNodeId, @@ -245,6 +292,18 @@ public class BCWebService extends AbstractCourseNodeWebService { */ @POST @Path("{nodeId}") + @Operation(summary = "update a Folder Element onto course", + description = "This updates a Folder Element onto a given course") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The folder node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response updateFolder(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @@ -271,6 +330,18 @@ public class BCWebService extends AbstractCourseNodeWebService { */ @GET @Path("{nodeId}") + @Operation(summary = "Retrieves metadata of the course node", + description = "Retrieves metadata of the course node") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = FolderVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = FolderVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getFolder(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) { ICourse course = CoursesWebService.loadCourse(courseId); @@ -314,6 +385,13 @@ public class BCWebService extends AbstractCourseNodeWebService { * @return */ @Path("{nodeId}/files") + @Operation(summary = "Return the FX implementation to manage a folder", + description = "Return the FX implementation to manage a folder") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok" + + )} + ) public VFSWebservice getVFSWebService(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest request) { ICourse course = CoursesWebService.loadCourse(courseId); if(course == null) { diff --git a/src/main/java/org/olat/course/nodes/co/COWebService.java b/src/main/java/org/olat/course/nodes/co/COWebService.java index 75a3099195b..900e4d11dbc 100755 --- a/src/main/java/org/olat/course/nodes/co/COWebService.java +++ b/src/main/java/org/olat/course/nodes/co/COWebService.java @@ -63,8 +63,15 @@ import org.olat.group.BusinessGroupService; import org.olat.group.BusinessGroupShort; import org.olat.modules.ModuleConfiguration; import org.olat.restapi.repository.course.AbstractCourseNodeWebService; +import org.olat.restapi.support.vo.CourseNodeVO; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -112,15 +119,28 @@ public class COWebService extends AbstractCourseNodeWebService { * @return The persisted contact element (fully populated) */ @PUT + @Operation(summary = "attach a contact element onto a given course", + description = "This attaches a contact element onto a given course, the element will be\n" + + " inserted underneath the supplied parentNodeId") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response attachContact(@PathParam("courseId") Long courseId, @QueryParam("parentNodeId") String parentNodeId, - @QueryParam("position") Integer position, @QueryParam("shortTitle") @DefaultValue("undefined") String shortTitle, - @QueryParam("longTitle") @DefaultValue("undefined") String longTitle, @QueryParam("objectives") @DefaultValue("undefined") String objectives, - @QueryParam("visibilityExpertRules") String visibilityExpertRules, @QueryParam("accessExpertRules") String accessExpertRules, - @QueryParam("coaches") @DefaultValue("false") boolean coaches, @QueryParam("participants") @DefaultValue("false") boolean participants, - @QueryParam("groups") String groups, @QueryParam("areas") String areas, @QueryParam("to") String to, - @QueryParam("defaultSubject") String defaultSubject, @QueryParam("defaultBody") String defaultBody, + @QueryParam("position") @Parameter(description = "The node's position relative to its sibling nodes (optional)") Integer position, @QueryParam("shortTitle") @Parameter(description = "The node short title") @DefaultValue("undefined") String shortTitle, + @QueryParam("longTitle") @Parameter(description = "The node long title") @DefaultValue("undefined") String longTitle, @QueryParam("objectives") @Parameter(description = "The node learning objectives") @DefaultValue("undefined") String objectives, + @QueryParam("visibilityExpertRules") @Parameter(description = "The rules to view the node (optional)") String visibilityExpertRules, @QueryParam("accessExpertRules") @Parameter(description = "The rules to access the node (optional)") String accessExpertRules, + @QueryParam("coaches") @Parameter(description = "Send to coaches (true/false)") @DefaultValue("false") boolean coaches, @QueryParam("participants") @Parameter(description = "Send to participants (true/false)") @DefaultValue("false") boolean participants, + @QueryParam("groups") @Parameter(description = "A list of learning groups (list of keys)") String groups, @QueryParam("areas") @Parameter(description = "A list of learning areas (list of keys)") String areas, @QueryParam("to") String to, + @QueryParam("defaultSubject") @Parameter(description = "The default subject") String defaultSubject, @QueryParam("defaultBody") @Parameter(description = "The default body text") String defaultBody, @Context HttpServletRequest request) { ContactConfigDelegate config = new ContactConfigDelegate(coaches, participants, groups, areas, to, defaultSubject, defaultBody); @@ -158,6 +178,19 @@ public class COWebService extends AbstractCourseNodeWebService { * @return The persisted contact element (fully populated) */ @POST + @Operation(summary = "attach a contact element onto a given course", + description = "This attaches a contact element onto a given course, the element will be\n" + + " inserted underneath the supplied parentNodeId") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response attachContactPost(@PathParam("courseId") Long courseId, @FormParam("parentNodeId") String parentNodeId, diff --git a/src/main/java/org/olat/course/nodes/en/ENWebService.java b/src/main/java/org/olat/course/nodes/en/ENWebService.java index 94dba4481a0..d8e8c5f2476 100644 --- a/src/main/java/org/olat/course/nodes/en/ENWebService.java +++ b/src/main/java/org/olat/course/nodes/en/ENWebService.java @@ -50,10 +50,17 @@ import org.olat.group.BusinessGroupShort; import org.olat.modules.ModuleConfiguration; import org.olat.restapi.repository.course.AbstractCourseNodeWebService; import org.olat.restapi.repository.course.CoursesWebService; +import org.olat.restapi.support.vo.CourseNodeVO; import org.olat.restapi.support.vo.GroupVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -98,13 +105,26 @@ public class ENWebService extends AbstractCourseNodeWebService { * @return The persisted contact element (fully populated) */ @PUT + @Operation(summary = "attach an enrollment element onto a given course", + description = "This attaches a contact element onto a given course, the element will be\n" + + " inserted underneath the supplied parentNodeId") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response attachEnrolmment(@PathParam("courseId") Long courseId, @QueryParam("parentNodeId") String parentNodeId, - @QueryParam("position") Integer position, @QueryParam("shortTitle") @DefaultValue("undefined") String shortTitle, - @QueryParam("longTitle") @DefaultValue("undefined") String longTitle, @QueryParam("objectives") @DefaultValue("undefined") String objectives, - @QueryParam("visibilityExpertRules") String visibilityExpertRules, @QueryParam("accessExpertRules") String accessExpertRules, - @QueryParam("groups") String groups, @QueryParam("cancelEnabled") @DefaultValue("false") boolean cancelEnabled, + public Response attachEnrolmment(@PathParam("courseId") Long courseId, @QueryParam("parentNodeId") @Parameter(description = "The node's id which will be the parent of this structure") String parentNodeId, + @QueryParam("position") @Parameter(description = "The node's position relative to its sibling nodes (optional)")Integer position, @QueryParam("shortTitle") @Parameter(description = "The node short title") @DefaultValue("undefined") String shortTitle, + @QueryParam("longTitle") @Parameter(description = "The node long title") @DefaultValue("undefined") String longTitle, @QueryParam("objectives") @Parameter(description = "The node learning objectives") @DefaultValue("undefined") String objectives, + @QueryParam("visibilityExpertRules") @Parameter(description = "The rules to view the node (optional)") String visibilityExpertRules, @QueryParam("accessExpertRules") @Parameter(description = "The rules to access the node (optional)") String accessExpertRules, + @QueryParam("groups") @Parameter(description = "A list of learning groups (list of keys)") String groups, @QueryParam("cancelEnabled") @Parameter(description = "cancel enrollment enabled or not") @DefaultValue("false") boolean cancelEnabled, @Context HttpServletRequest request) { EnrollmentConfigDelegate config = new EnrollmentConfigDelegate(groups, cancelEnabled); @@ -137,6 +157,19 @@ public class ENWebService extends AbstractCourseNodeWebService { * @return The persisted contact element (fully populated) */ @POST + @Operation(summary = "attach an enrollment element onto a given course", + description = "This attaches a contact element onto a given course, the element will be\n" + + " inserted underneath the supplied parentNodeId") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response attachEnrollmenetPost(@PathParam("courseId") Long courseId, @FormParam("parentNodeId") String parentNodeId, @@ -153,7 +186,7 @@ public class ENWebService extends AbstractCourseNodeWebService { * Retrieves the groups where the enrollment happens * @response.representation.200.qname {http://www.example.com}groupVO * @response.representation.200.mediaType application/xml, application/json - * @response.representation.200.doc The groups + * @response.representation.200.doc Retrieves the groups where the enrollment happens * @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVO} * @response.representation.401.doc The roles of the authenticated user are not sufficient * @response.representation.404.doc The course or course node not found @@ -163,6 +196,18 @@ public class ENWebService extends AbstractCourseNodeWebService { */ @GET @Path("{nodeId}/groups") + @Operation(summary = "Retrieves the groups where the enrollment happens", + description = "Retrieves the groups where the enrollment happens") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Retrieves the groups where the enrollment happens", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = GroupVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = GroupVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getGroups(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) { ICourse course = CoursesWebService.loadCourse(courseId); diff --git a/src/main/java/org/olat/modules/curriculum/restapi/CurriculumElementTypesWebService.java b/src/main/java/org/olat/modules/curriculum/restapi/CurriculumElementTypesWebService.java index 503ea870236..2b102c65c19 100644 --- a/src/main/java/org/olat/modules/curriculum/restapi/CurriculumElementTypesWebService.java +++ b/src/main/java/org/olat/modules/curriculum/restapi/CurriculumElementTypesWebService.java @@ -20,6 +20,7 @@ package org.olat.modules.curriculum.restapi; import java.util.ArrayList; + import java.util.List; import java.util.Set; @@ -45,6 +46,12 @@ import org.olat.modules.curriculum.model.CurriculumElementTypeRefImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -67,13 +74,24 @@ public class CurriculumElementTypesWebService { * * @response.representation.200.qname {http://www.example.com}curriculumElementTypeVO * @response.representation.200.mediaType application/xml, application/json - * @response.representation.200.doc An array of curriculum element typess + * @response.representation.200.doc An array of curriculum element types * @response.representation.200.example {@link org.olat.modules.curriculum.restapi.Examples#SAMPLE_CURRICULUMELEMENTTYPEVO} * @response.representation.401.doc The roles of the authenticated user are not sufficient * @param httpRequest The HTTP request * @return An array of curriculum element types */ @GET + @Operation(summary = "Return the curriculum element types", + description = "Return the curriculum element types used in the whole OpenOLAT instance") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "An array of curriculum element types", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = CurriculumElementTypeVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = CurriculumElementTypeVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient.")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getElementTypes() { List<CurriculumElementType> elementTypes = curriculumService.getCurriculumElementTypes(); @@ -101,6 +119,18 @@ public class CurriculumElementTypesWebService { * @return The new persisted <code>curriculum element type</code> */ @PUT + @Operation(summary = "Create and persists a new curriculum element type entity", + description = "Creates and persists a new curriculum element type entity") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The persisted curriculum element type", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementTypeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementTypeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "406", description = "application/xml, application/json.")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putCurriculumElementType(CurriculumElementTypeVO curriculumelementType) { @@ -124,6 +154,18 @@ public class CurriculumElementTypesWebService { * @return The merged <code>curriculum element type</code> */ @POST + @Operation(summary = "Update a new curriculum element type entity", + description = "Updates a new curriculum element type entity") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The merged curriculum element type", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementTypeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementTypeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "406", description = "application/xml, application/json.")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response postCurriculumElementType(CurriculumElementTypeVO curriculumElementType) { @@ -150,6 +192,19 @@ public class CurriculumElementTypesWebService { */ @POST @Path("{curriculumElementTypeKey}") + @Operation(summary = "Update a new curriculum element type entity", + description = "Updates a new curriculum element type entity. The primary key is taken from\n" + + " the URL. The curriculum element type object can be \"primary key free\"") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The merged type curriculum element", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementTypeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementTypeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "406", description = "application/xml, application/json.")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response postCurriculumElementType(@PathParam("curriculumElementTypeKey") Long curriculumElementTypeKey, @@ -199,6 +254,17 @@ public class CurriculumElementTypesWebService { */ @GET @Path("{curriculumElementTypeKey}") + @Operation(summary = "Get a specific curriculum element type", + description = "Get a specific curriculum element type") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The merged type curriculum element", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementTypeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementTypeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient.")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCurriculumElementTypes(@PathParam("curriculumElementTypeKey") Long curriculumElementTypeKey) { CurriculumElementType elementType = curriculumService.getCurriculumElementType(new CurriculumElementTypeRefImpl(curriculumElementTypeKey)); @@ -222,6 +288,18 @@ public class CurriculumElementTypesWebService { */ @GET @Path("{curriculumElementTypeKey}/allowedSubTypes") + @Operation(summary = "Get the allowed sub-types", + description = "Get the allowed sub-types of a specified curriculum element type") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "An array of curriculum element types", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = CurriculumElementTypeVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = CurriculumElementTypeVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "405", description = "The curriculum element type was not found")} + ) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getAllowedSubTypes(@PathParam("curriculumElementTypeKey") Long curriculumElementTypeKey) { CurriculumElementType type = curriculumService.getCurriculumElementType(new CurriculumElementTypeRefImpl(curriculumElementTypeKey)); @@ -252,6 +330,14 @@ public class CurriculumElementTypesWebService { */ @PUT @Path("{curriculumElementTypeKey}/allowedSubTypes/{subTypeKey}") + @Operation(summary = "Add a sub-type to a specified curriculum element type", + description = "Add a sub-type to a specified curriculum element type") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The sub type was added to the allowed sub types" + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "405", description = "The curriculum element type was not found")} + ) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response allowSubTaxonomyLevelType(@PathParam("curriculumElementTypeKey") Long curriculumElementTypeKey, @PathParam("subTypeKey") Long subTypeKey) { CurriculumElementType type = curriculumService.getCurriculumElementType(new CurriculumElementTypeRefImpl(curriculumElementTypeKey)); @@ -276,6 +362,13 @@ public class CurriculumElementTypesWebService { */ @DELETE @Path("{curriculumElementTypeKey}/allowedSubTypes/{subTypeKey}") + @Operation(summary = "Remove a sub-type to a specified curriculum element type", + description = "Remove a sub-type to a specified curriculum element type") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The sub type was removed successfully"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "405", description = "The curriculum element type was not found")} + ) public Response disalloweSubType(@PathParam("curriculumElementTypeKey") Long curriculumElementTypeKey, @PathParam("subTypeKey") Long subTypeKey) { CurriculumElementType type = curriculumService.getCurriculumElementType(new CurriculumElementTypeRefImpl(curriculumElementTypeKey)); CurriculumElementType subType = curriculumService.getCurriculumElementType(new CurriculumElementTypeRefImpl(subTypeKey)); diff --git a/src/main/java/org/olat/modules/curriculum/restapi/CurriculumElementsWebService.java b/src/main/java/org/olat/modules/curriculum/restapi/CurriculumElementsWebService.java index b44bd84e51d..1e4e202c357 100644 --- a/src/main/java/org/olat/modules/curriculum/restapi/CurriculumElementsWebService.java +++ b/src/main/java/org/olat/modules/curriculum/restapi/CurriculumElementsWebService.java @@ -20,6 +20,7 @@ package org.olat.modules.curriculum.restapi; import java.util.ArrayList; + import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -69,6 +70,13 @@ import org.olat.user.restapi.UserVO; import org.olat.user.restapi.UserVOFactory; import org.springframework.beans.factory.annotation.Autowired; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + /** * The security checks are done by the CurriculumsWebService. * @@ -111,6 +119,17 @@ public class CurriculumElementsWebService { * @return The taxonomy */ @GET + @Operation(summary = "Return the curriculum elements of a curriculum", + description = "Return the curriculum elements of a curriculum") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "A taxonomy", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCurriculumElements() { List<CurriculumElement> elements = curriculumService.getCurriculumElements(curriculum, CurriculumElementStatus.notDeleted()); @@ -135,6 +154,17 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}") + @Operation(summary = "Get a specific curriculum element", + description = "Get a specific curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The curriculum element", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCurriculumElement(@PathParam("curriculumElementKey") Long curriculumElementKey, @Context HttpServletRequest httpRequest) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -161,6 +191,18 @@ public class CurriculumElementsWebService { * @return The new persisted <code>curriculum element</code> */ @PUT + @Operation(summary = "Creates and persists a new curriculum element entity", + description = "Creates and persists a new curriculum element entity") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The curriculum element to persist", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "406", description = "application/xml, application/json")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putCurriculumElement(CurriculumElementVO curriculumElement) @@ -185,6 +227,18 @@ public class CurriculumElementsWebService { * @return The merged <code>curriculum element</code> */ @POST + @Operation(summary = "Updates a curriculum element entity", + description = "Updates a curriculum element entity") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The curriculum element to update", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "406", description = "application/xml, application/json")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response postCurriculumElement(CurriculumElementVO curriculumElement) @@ -212,6 +266,19 @@ public class CurriculumElementsWebService { */ @POST @Path("{curriculumElementKey}") + @Operation(summary = "Updates a curriculum element entity", + description = "Updates a curriculum element entity. The primary key is taken from\n" + + " the URL. The curriculum element object can be \"primary key free\"") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The curriculum element to update", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "406", description = "application/xml, application/json")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response postCurriculumElement(@PathParam("curriculumElementKey") Long curriculumElementKey, CurriculumElementVO curriculumElement) @@ -311,6 +378,18 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/elements") + @Operation(summary = "Get the curriculum elements", + description = "Get the curriculum elements laying under the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The curriculum elements under the specified element", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = CurriculumElementVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = CurriculumElementVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element was not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCurriculumElementChildren(@PathParam("curriculumElementKey") Long curriculumElementKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -344,6 +423,18 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/entries") + @Operation(summary = "Get the repository entries", + description = "Get the repository entries laying under the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The repository entries", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = RepositoryEntryVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = RepositoryEntryVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the repository entry was not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getRepositoryEntriesInElement(@PathParam("curriculumElementKey") Long curriculumElementKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -373,6 +464,13 @@ public class CurriculumElementsWebService { */ @HEAD @Path("{curriculumElementKey}/entries/{repositoryEntryKey}") + @Operation(summary = "see if a repository entry is under curriculum element", + description = "To see if a repository entry is under the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The repository entry is there"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the repository entry was not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response headRepositoryEntryInElement(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("repositoryEntryKey") Long repositoryEntryKey) { @@ -409,6 +507,18 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/entries/{repositoryEntryKey}") + @Operation(summary = "Load the repository entry", + description = "Load the repository entry laying under the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The repository entries", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = RepositoryEntryVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = RepositoryEntryVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the repository entry was not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getRepositoryEntryInElement(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("repositoryEntryKey") Long repositoryEntryKey) { @@ -442,6 +552,14 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/entries/{repositoryEntryKey}") + @Operation(summary = "Add a relation", + description = "Add a relation between a repository entry and a curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The relation was added"), + @ApiResponse(responseCode = "304", description = "There is already a relation, nothing changed"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the repository entry was not found")} + ) public Response addRepositoryEntryToElement(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("repositoryEntryKey") Long repositoryEntryKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -477,6 +595,14 @@ public class CurriculumElementsWebService { */ @DELETE @Path("{curriculumElementKey}/entries/{repositoryEntryKey}") + @Operation(summary = "Remove a relation", + description = "Remove a relation between a curriculum element and a repository entry") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The relation was successfully removed"), + @ApiResponse(responseCode = "304", description = "here is no relation to remove"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the repository entry was not found")} + ) public Response removeRepositoryEntryToElement(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("repositoryEntryKey") Long repositoryEntryKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -512,6 +638,17 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/members") + @Operation(summary = "Get memberships informations", + description = "Get the memberships informations of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The curriculum element membership", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumElementMemberVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumElementMemberVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient")} + ) public Response getMembers(@PathParam("curriculumElementKey") Long curriculumElementKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); if(curriculumElement == null) { @@ -544,6 +681,19 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/users") + @Operation(summary = "Get all members", + description = "Get all members of the specified curriculum element. A query parameter can\n" + + " specify the role of them") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The array of authors", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "401", description = "The course not found")} + ) public Response getUsers(@PathParam("curriculumElementKey") Long curriculumElementKey, @QueryParam("role") String role) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); if(curriculumElement == null) { @@ -581,6 +731,14 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/members") + @Operation(summary = "Add a membership ", + description = "Add a membership to the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was persisted"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found"), + @ApiResponse(responseCode = "409", description = "The role is not allowed")} + ) public Response putMembers(@PathParam("curriculumElementKey") Long curriculumElementKey, CurriculumElementMemberVO membership) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -615,6 +773,13 @@ public class CurriculumElementsWebService { */ @DELETE @Path("{curriculumElementKey}/members/{identityKey}") + @Operation(summary = "Remove all memberships ", + description = "Remove all memberships of the identity from the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was removed"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found")} + ) public Response deleteMembers(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -647,6 +812,18 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/participants") + @Operation(summary = "Get all participants", + description = "Get all participants of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The array of participants", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getParticipants(@PathParam("curriculumElementKey") Long curriculumElementKey) { return getMembers(curriculumElementKey, CurriculumRoles.participant); @@ -666,6 +843,18 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/coaches") + @Operation(summary = "Get all coaches", + description = "Get all coaches of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The array of coaches", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCoaches(@PathParam("curriculumElementKey") Long curriculumElementKey) { return getMembers(curriculumElementKey, CurriculumRoles.coach); @@ -685,6 +874,18 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/owners") + @Operation(summary = "Get all owners", + description = "Get all owners of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The array of owners", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getOwners(@PathParam("curriculumElementKey") Long curriculumElementKey) { return getMembers(curriculumElementKey, CurriculumRoles.owner); @@ -704,6 +905,18 @@ public class CurriculumElementsWebService { */ @GET @Path("{curriculumElementKey}/mastercoaches") + @Operation(summary = "Get all master coaches", + description = "Get all master coaches of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The array of master coaches", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getMasterCoaches(@PathParam("curriculumElementKey") Long curriculumElementKey) { return getMembers(curriculumElementKey, CurriculumRoles.mastercoach); @@ -722,7 +935,19 @@ public class CurriculumElementsWebService { * @return It returns an array of <code>UserVO</code> */ @GET - @Path("{curriculumElementKey}/curriculumelementowners") + @Path("{curriculumElementKey}/curriculumelementowners") + @Operation(summary = "Get all curriculum managers", + description = "Get all curriculum managers of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The array of curriculum managers", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCurriculumManagers(@PathParam("curriculumElementKey") Long curriculumElementKey) { return getMembers(curriculumElementKey, CurriculumRoles.curriculumelementowner); @@ -756,6 +981,13 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/participants/{identityKey}") + @Operation(summary = "Make the specified user a participant of the curriculum element ", + description = "Make the specified user a participant of the curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was added"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found")} + ) public Response putParticipant(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return putMember(curriculumElementKey, identityKey, CurriculumRoles.participant); } @@ -772,6 +1004,13 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/coaches/{identityKey}") + @Operation(summary = "Make the specified user a coach of the curriculum element", + description = "Make the specified user a coach of the curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was added"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found")} + ) public Response putCoach(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return putMember(curriculumElementKey, identityKey, CurriculumRoles.coach); } @@ -788,6 +1027,13 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/owners/{identityKey}") + @Operation(summary = "Make the specified user a course owner of the curriculum element", + description = "Make the specified user a course owner of the curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was added"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found")} + ) public Response putOwner(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return putMember(curriculumElementKey, identityKey, CurriculumRoles.owner); } @@ -804,6 +1050,13 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/curriculumelementowners/{identityKey}") + @Operation(summary = "Make the specified user a curriculum manager of the curriculum element", + description = "Make the specified user a curriculum manager of the curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was added"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found")} + ) public Response putCurriculumElementOwner(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return putMember(curriculumElementKey, identityKey, CurriculumRoles.curriculumelementowner); } @@ -820,6 +1073,13 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/mastercoaches/{identityKey}") + @Operation(summary = "Make the specified user a master coach of the curriculum element", + description = "Make the specified user a master coach of the curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was added"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found")} + ) public Response putMasterCoach(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return putMember(curriculumElementKey, identityKey, CurriculumRoles.mastercoach); } @@ -858,6 +1118,19 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/participants") + @Operation(summary = "Make the array of users participant of the specified curriculum element", + description = "Make the array of users participant of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The memberships was persisted", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found"), + @ApiResponse(responseCode = "409", description = "The role is not allowed")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putParticipants(@PathParam("curriculumElementKey") Long curriculumElementKey, UserVO[] participants) { return putMembers(curriculumElementKey, participants, CurriculumRoles.participant); @@ -880,6 +1153,14 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/coaches") + @Operation(summary = "Make the array of users coach of the specified curriculum element", + description = "Make the array of users coach of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The memberships was persisted"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found"), + @ApiResponse(responseCode = "409", description = "The role is not allowed")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putCoaches(@PathParam("curriculumElementKey") Long curriculumElementKey, UserVO[] coaches) { return putMembers(curriculumElementKey, coaches, CurriculumRoles.coach); @@ -902,6 +1183,14 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/owners") + @Operation(summary = "Make the array of users course owner of the specified curriculum element", + description = "Make the array of users course owner of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The memberships was persisted"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found"), + @ApiResponse(responseCode = "409", description = "The role is not allowed")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putOwners(@PathParam("curriculumElementKey") Long curriculumElementKey, UserVO[] owners) { return putMembers(curriculumElementKey, owners, CurriculumRoles.owner); @@ -924,6 +1213,14 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/mastercoaches") + @Operation(summary = "Make the array of users course master coaches of the specified curriculum element", + description = "Make the array of users course master coaches of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The memberships was persisted"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found"), + @ApiResponse(responseCode = "409", description = "The role is not allowed")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putMasterCoaches(@PathParam("curriculumElementKey") Long curriculumElementKey, UserVO[] masterCoaches) { return putMembers(curriculumElementKey, masterCoaches, CurriculumRoles.mastercoach); @@ -946,6 +1243,14 @@ public class CurriculumElementsWebService { */ @PUT @Path("{curriculumElementKey}/curriculumelementowners") + @Operation(summary = "Make the array of users curriculum managers of the specified curriculum element", + description = "Make the array of users curriculum managers of the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The memberships was persisted"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found"), + @ApiResponse(responseCode = "409", description = "The role is not allowed")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putCurriculumManagers(@PathParam("curriculumElementKey") Long curriculumElementKey, UserVO[] coaches) { return putMembers(curriculumElementKey, coaches, CurriculumRoles.curriculumelementowner); @@ -981,6 +1286,13 @@ public class CurriculumElementsWebService { */ @DELETE @Path("{curriculumElementKey}/participants/{identityKey}") + @Operation(summary = "Remove the participant membership", + description = "Remove the participant membership of the identity from the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was removed"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) public Response deleteParticipant(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return deleteMember(curriculumElementKey, identityKey, CurriculumRoles.participant); @@ -998,6 +1310,13 @@ public class CurriculumElementsWebService { */ @DELETE @Path("{curriculumElementKey}/coaches/{identityKey}") + @Operation(summary = "Remove the coach membership", + description = "Remove the coach membership of the identity from the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was removed"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) public Response deleteCoach(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return deleteMember(curriculumElementKey, identityKey, CurriculumRoles.coach); @@ -1015,6 +1334,13 @@ public class CurriculumElementsWebService { */ @DELETE @Path("{curriculumElementKey}/owners/{identityKey}") + @Operation(summary = "Remove the owners membership", + description = "Remove the owners membership of the identity from the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was removed"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) public Response deleteOwner(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return deleteMember(curriculumElementKey, identityKey, CurriculumRoles.owner); @@ -1032,6 +1358,13 @@ public class CurriculumElementsWebService { */ @DELETE @Path("{curriculumElementKey}/mastercoaches/{identityKey}") + @Operation(summary = "Remove the master coach membership", + description = "Remove the master coach membership of the identity from the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was removed"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) public Response deleteMasterCoach(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return deleteMember(curriculumElementKey, identityKey, CurriculumRoles.mastercoach); @@ -1049,6 +1382,13 @@ public class CurriculumElementsWebService { */ @DELETE @Path("{curriculumElementKey}/curriculumelementowners/{identityKey}") + @Operation(summary = "Remove the curriculum manager membership", + description = "Remove the curriculum manager membership of the identity from the specified curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was removed"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element not found")} + ) public Response deleteCurriculumManager(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("identityKey") Long identityKey) { return deleteMember(curriculumElementKey, identityKey, CurriculumRoles.curriculumelementowner); @@ -1073,6 +1413,18 @@ public class CurriculumElementsWebService { @GET @Path("{curriculumElementKey}/taxonomy/levels") + @Operation(summary = "Get levels", + description = "Get levels from a specific curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The list of levels", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = TaxonomyLevelVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = TaxonomyLevelVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum or curriculum element not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getTaxonomyLevels(@PathParam("curriculumElementKey") Long curriculumElementKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -1092,6 +1444,18 @@ public class CurriculumElementsWebService { @PUT @Path("{curriculumElementKey}/taxonomy/levels/{taxonomyLevelKey}") + @Operation(summary = "Put level", + description = "Put level from a specific curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The level", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = TaxonomyLevelVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = TaxonomyLevelVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum or curriculum element not found")} + ) public Response getTaxonomyLevels(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("taxonomyLevelKey") Long taxonomyLevelKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); @@ -1119,6 +1483,14 @@ public class CurriculumElementsWebService { @DELETE @Path("{curriculumElementKey}/taxonomy/levels/{taxonomyLevelKey}") + @Operation(summary = "Delete level", + description = "Delete level from a specific curriculum element") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Remove level" + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum or curriculum element not found")} + ) public Response deleteTaxonomyLevel(@PathParam("curriculumElementKey") Long curriculumElementKey, @PathParam("taxonomyLevelKey") Long taxonomyLevelKey) { CurriculumElement curriculumElement = curriculumService.getCurriculumElement(new CurriculumElementRefImpl(curriculumElementKey)); diff --git a/src/main/java/org/olat/modules/curriculum/restapi/CurriculumsWebService.java b/src/main/java/org/olat/modules/curriculum/restapi/CurriculumsWebService.java index af609ab55d4..d706e623921 100644 --- a/src/main/java/org/olat/modules/curriculum/restapi/CurriculumsWebService.java +++ b/src/main/java/org/olat/modules/curriculum/restapi/CurriculumsWebService.java @@ -62,6 +62,12 @@ import org.olat.user.restapi.UserVOFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -85,7 +91,7 @@ public class CurriculumsWebService { private OrganisationService organisationService; /** - * The version of the User Web Service + * * @response.representation.200.mediaType text/plain * @response.representation.200.doc The version of this specific Web Service * @response.representation.200.example 1.0 @@ -93,6 +99,11 @@ public class CurriculumsWebService { */ @GET @Path("version") + @Operation(summary = "Get the version of the User Web Service", + description = "Get the version of the User Web Service") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The version of this specific Web Service")} + ) @Produces(MediaType.TEXT_PLAIN) public Response getVersion() { return Response.ok(VERSION).build(); @@ -110,6 +121,17 @@ public class CurriculumsWebService { * @return An array of curriculums */ @GET + @Operation(summary = "Return the curriculums a manager user is allowed to see", + description = "Return the curriculums a manager user is allowed to see") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "An array of curriculums", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = CurriculumVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = CurriculumVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCurriculums(@Context HttpServletRequest httpRequest) { Roles roles = getRoles(httpRequest); @@ -157,6 +179,18 @@ public class CurriculumsWebService { * @return The new persisted <code>curriculum</code> */ @PUT + @Operation(summary = "Creates and persists a new curriculum", + description = "Creates and persists a new curriculum") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The persisted curriculum", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "406", description = "application/xml, application/json")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response putCurriculum(CurriculumVO curriculum, @Context HttpServletRequest httpRequest) { @@ -186,6 +220,18 @@ public class CurriculumsWebService { * @return The merged <code>curriculum</code> */ @POST + @Operation(summary = "Updates a curriculum entity", + description = "Updates a curriculum entity") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The curriculum to update", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "406", description = "application/xml, application/json")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response postCurriculum(CurriculumVO curriculum, @Context HttpServletRequest httpRequest) { @@ -212,6 +258,18 @@ public class CurriculumsWebService { */ @GET @Path("{curriculumKey}") + @Operation(summary = "Get a specific curriculum", + description = "Get a specific curriculum") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The curriculum", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "406", description = "application/xml, application/json")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCurriculum(@PathParam("curriculumKey") Long curriculumKey, @Context HttpServletRequest httpRequest) { Curriculum curriculum = curriculumService.getCurriculum(new CurriculumRefImpl(curriculumKey)); @@ -255,6 +313,19 @@ public class CurriculumsWebService { */ @POST @Path("{curriculumKey}") + @Operation(summary = "Update a curriculum entity", + description = "Updates a curriculum entity. The primary key is taken from\n" + + " the URL. The curriculum object can be \"primary key free\"") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The merged curriculum", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CurriculumVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CurriculumVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "406", description = "application/xml, application/json")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response postCurriculum(@PathParam("curriculumKey") Long curriculumKey, CurriculumVO curriculum, @Context HttpServletRequest httpRequest) { @@ -350,6 +421,18 @@ public class CurriculumsWebService { */ @GET @Path("{curriculumKey}/curriculumowners") + @Operation(summary = "Get all curriculum managers", + description = "Get all curriculum managers of the specified curriculum") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The array of curriculum managers", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = UserVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "406", description = "application/xml, application/json")} + ) public Response getCurriculumManagers(@PathParam("curriculumKey") Long curriculumKey, @Context HttpServletRequest httpRequest) { return getMembers(curriculumKey, CurriculumRoles.curriculumowner, httpRequest); } @@ -383,6 +466,13 @@ public class CurriculumsWebService { */ @PUT @Path("{curriculumKey}/curriculumowners/{identityKey}") + @Operation(summary = "Make the specified user a curriculum manager of the curriculum", + description = "Make the specified user a curriculum manager of the curriculum") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was added"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found")} + ) public Response putCurriculumOwner(@PathParam("curriculumKey") Long curriculumKey, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest) { return putMember(curriculumKey, identityKey, CurriculumRoles.curriculumowner, httpRequest); @@ -417,6 +507,13 @@ public class CurriculumsWebService { */ @DELETE @Path("{curriculumKey}/curriculumowners/{identityKey}") + @Operation(summary = "Remove the curriculum manager membership", + description = "Remove the curriculum manager membership of the identity from the specified curriculum") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The membership was removed"), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The curriculum element or the identity was not found")} + ) public Response deleteCurriculumManager(@PathParam("curriculumKey") Long curriculumKey, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest) { return deleteMember(curriculumKey, identityKey, CurriculumRoles.curriculumowner, httpRequest); diff --git a/src/main/java/org/olat/modules/docpool/restapi/DocumentPoolModuleWebService.java b/src/main/java/org/olat/modules/docpool/restapi/DocumentPoolModuleWebService.java index 8c7a8d3b757..251d294b76a 100644 --- a/src/main/java/org/olat/modules/docpool/restapi/DocumentPoolModuleWebService.java +++ b/src/main/java/org/olat/modules/docpool/restapi/DocumentPoolModuleWebService.java @@ -39,8 +39,14 @@ import org.olat.modules.taxonomy.Taxonomy; import org.olat.modules.taxonomy.TaxonomyService; import org.olat.modules.taxonomy.model.TaxonomyRefImpl; import org.olat.modules.taxonomy.restapi.TaxonomyWebService; +import org.olat.restapi.support.vo.CourseNodeVO; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -67,6 +73,17 @@ public class DocumentPoolModuleWebService { */ @GET @Path("module/configuration") + @Operation(summary = "Return the configuration of the taxonomy module", + description = "Return the configuration of the taxonomy module") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The configuration of the taxonomy module", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = DocumentPoolModuleConfigurationVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = DocumentPoolModuleConfigurationVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient")} + ) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getModuleConfiguration(@Context HttpServletRequest httpRequest) { Roles roles = getRoles(httpRequest); diff --git a/src/main/java/org/olat/modules/fo/restapi/ForumCourseNodeWebService.java b/src/main/java/org/olat/modules/fo/restapi/ForumCourseNodeWebService.java index bf00414e0ce..2b85e5d2cfc 100644 --- a/src/main/java/org/olat/modules/fo/restapi/ForumCourseNodeWebService.java +++ b/src/main/java/org/olat/modules/fo/restapi/ForumCourseNodeWebService.java @@ -73,9 +73,15 @@ import org.olat.restapi.repository.course.AbstractCourseNodeWebService; import org.olat.restapi.repository.course.CourseWebService; import org.olat.restapi.repository.course.CoursesWebService; import org.olat.restapi.security.RestSecurityHelper; +import org.olat.restapi.support.vo.CourseNodeVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -112,6 +118,18 @@ public class ForumCourseNodeWebService extends AbstractCourseNodeWebService { * @return The persisted structure element (fully populated) */ @GET + @Operation(summary = "Retrieves metadata of the published course node", + description = "Retrieves metadata of the published course node") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ForumVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = ForumVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getForums(@PathParam("courseId") Long courseId, @Context HttpServletRequest httpRequest) { final ICourse course = CoursesWebService.loadCourse(courseId); @@ -172,6 +190,19 @@ public class ForumCourseNodeWebService extends AbstractCourseNodeWebService { * @return The persisted Forum Element (fully populated) */ @POST + @Operation(summary = "attach a Forum Element onto a given course", + description = "This attaches a Forum Element onto a given course. The element will be\n" + + " inserted underneath the supplied parentNodeId") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response attachForumPost(@PathParam("courseId") Long courseId, @FormParam("parentNodeId") String parentNodeId, @@ -206,6 +237,19 @@ public class ForumCourseNodeWebService extends AbstractCourseNodeWebService { * @return The persisted Forum Element (fully populated) */ @PUT + @Operation(summary = "attach a Forum Element onto a given course", + description = "This attaches a Forum Element onto a given course. The element will be\n" + + " inserted underneath the supplied parentNodeId") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = CourseNodeVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = CourseNodeVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response attachForum(@PathParam("courseId") Long courseId, @QueryParam("parentNodeId") String parentNodeId, @QueryParam("position") Integer position, @QueryParam("shortTitle") @DefaultValue("undefined") String shortTitle, @@ -232,6 +276,18 @@ public class ForumCourseNodeWebService extends AbstractCourseNodeWebService { */ @GET @Path("{nodeId}") + @Operation(summary = "Retrieve metadata of the published course node", + description = "Retrieves metadata of the published course node") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ForumVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = ForumVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getForum(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) { ICourse course = CoursesWebService.loadCourse(courseId); @@ -315,6 +371,18 @@ public class ForumCourseNodeWebService extends AbstractCourseNodeWebService { */ @PUT @Path("{nodeId}/thread") + @Operation(summary = "Create a new thread in the forum of the course node", + description = "Creates a new thread in the forum of the course node") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "The course node metadatas", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = MessageVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The course or parentNode not found")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response newThreadToForum(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @QueryParam("title") String title, @QueryParam("body") String body, @QueryParam("identityName") String identityName, @QueryParam("sticky") Boolean isSticky, diff --git a/src/main/java/org/olat/modules/fo/restapi/ForumWebService.java b/src/main/java/org/olat/modules/fo/restapi/ForumWebService.java index 2b7a8dd611c..053de7c1d6d 100644 --- a/src/main/java/org/olat/modules/fo/restapi/ForumWebService.java +++ b/src/main/java/org/olat/modules/fo/restapi/ForumWebService.java @@ -86,6 +86,12 @@ import org.olat.restapi.support.vo.FileVO; import org.springframework.beans.factory.annotation.Autowired; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -130,6 +136,17 @@ public class ForumWebService { * @return The forum */ @GET + @Operation(summary = "Retrieves the forum of a group.", description = "Retrieves the forum of a group.") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Request was successful.", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ForumVO.class)), + @Content(mediaType = "application/xml",schema = @Schema(implementation = ForumVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The forum not found.")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getForum() { if(forum == null) { @@ -161,10 +178,20 @@ public class ForumWebService { @Path("threads") @Operation(summary = "Get threads", description = "Retrieves the threads in the forum.") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Request was successful.", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = MessageVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = MessageVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "404", description = "The author, forum or message not found.")} +) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response getThreads(@QueryParam("start") @DefaultValue("0") Integer start, - @QueryParam("limit") @DefaultValue("25") Integer limit, @QueryParam("orderBy") @DefaultValue("creationDate") String orderBy, - @QueryParam("asc") @DefaultValue("true") Boolean asc, @Context HttpServletRequest httpRequest, @Context UriInfo uriInfo, + public Response getThreads(@QueryParam("start") @Parameter(description = "Set the date for the earliest thread.")@DefaultValue("0") Integer start, + @QueryParam("limit") @Parameter(description = "Limit the amount of threads to be returned.") @DefaultValue("25") Integer limit, @QueryParam("orderBy") @Parameter(description = "orderBy (value name,creationDate)") @DefaultValue("creationDate") String orderBy, + @QueryParam("asc") @Parameter(description = "Determine the type of order.") @DefaultValue("true") Boolean asc, @Context HttpServletRequest httpRequest, @Context UriInfo uriInfo, @Context Request request) { if(forum == null) { return Response.serverError().status(Status.NOT_FOUND).build(); @@ -206,6 +233,16 @@ public class ForumWebService { @Path("threads") @Operation(summary = "Post threads", description = "Creates a new thread in the forum of the course node.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok.", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = MessageVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "404", description = "The author, forum or message not found.")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response newThreadToForumPost(@FormParam("title") String title, @@ -232,7 +269,18 @@ public class ForumWebService { @Path("threads") @Operation(summary = "Put threads", description = "Creates a new thread in the forum of the course node.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok.", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = MessageVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "404", description = "The author, forum or message not found.")} + ) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response newThreadToForum(@QueryParam("title") String title, @QueryParam("body") String body, @QueryParam("authorKey") Long authorKey, @Context HttpServletRequest httpRequest) { @@ -271,9 +319,19 @@ public class ForumWebService { @Path("posts/{threadKey}") @Operation(summary = "Get posts", description = "Retrieves the messages in the thread.") - public Response getMessages( @PathParam("threadKey") Long threadKey, @QueryParam("start") @DefaultValue("0") Integer start, - @QueryParam("limit") @DefaultValue("25") Integer limit, @QueryParam("orderBy") @DefaultValue("creationDate") String orderBy, - @QueryParam("asc") @DefaultValue("true") Boolean asc, @Context HttpServletRequest httpRequest, @Context UriInfo uriInfo, + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok.", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = MessageVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = MessageVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "404", description = "The author, forum or message not found.")} + ) + public Response getMessages( @PathParam("threadKey") Long threadKey, @QueryParam("start") @Parameter(description = "Set the date for the earliest thread.") @DefaultValue("0") Integer start, + @QueryParam("limit")@Parameter(description = "Limit the amount of threads to be returned.") @DefaultValue("25") Integer limit, @QueryParam("orderBy")@Parameter(description = "orderBy (value name,creationDate)") @DefaultValue("creationDate") String orderBy, + @QueryParam("asc") @Parameter(description = "Determine the type of order.") @DefaultValue("true") Boolean asc, @Context HttpServletRequest httpRequest, @Context UriInfo uriInfo, @Context Request request) { if(forum == null) { @@ -316,7 +374,17 @@ public class ForumWebService { @POST @Path("posts/{messageKey}") @Operation(summary = "Post posts", - description = "Creates a new reply in the forum of the course node.") + description = "Creates a new reply in the forum of the course node") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = MessageVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient"), + @ApiResponse(responseCode = "404", description = "The author or message not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response replyToPostPost(@PathParam("messageKey") Long messageKey, @FormParam("title") String title, @@ -345,6 +413,16 @@ public class ForumWebService { @Path("posts/{messageKey}") @Operation(summary = "Put posts", description = "Creates a new reply in the forum of the course node.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok.", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = MessageVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "404", description = "The author or message not found.")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response replyToPost(@PathParam("messageKey") Long messageKey, @QueryParam("title") String title, @@ -371,6 +449,16 @@ public class ForumWebService { @Path("posts/{messageKey}") @Operation(summary = "Put posts", description = "Creates a new reply in the forum of the course node.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok.", + content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = MessageVO.class)), + @Content(mediaType = "application/xml", schema = @Schema(implementation = MessageVO.class)) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "404", description = "The author or message not found.")} + ) @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response replyToPost(@PathParam("messageKey") Long messageKey, ReplyVO reply, @@ -437,6 +525,11 @@ public class ForumWebService { @Path("posts/{messageKey}/attachments") @Operation(summary = "Get attachments", description = "Retrieves the attachments of the message.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok." + ), + @ApiResponse(responseCode = "404", description = "The message not found")} + ) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getAttachments(@PathParam("messageKey") Long messageKey, @Context UriInfo uriInfo) { //load message @@ -466,6 +559,11 @@ public class ForumWebService { @Operation(summary = "Get attachment", description = "Retrieves the attachment of the message.") @Path("posts/{messageKey}/attachments/{filename}") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok." + ), + @ApiResponse(responseCode = "404", description = " The identity or the portrait not found")} + ) @Produces({"*/*", MediaType.APPLICATION_OCTET_STREAM}) public Response getAttachment(@PathParam("messageKey") Long messageKey, @PathParam("filename") String filename, @Context Request request) { @@ -517,9 +615,15 @@ public class ForumWebService { * @param request The HTTP request * @return Ok */ + @POST @Operation(summary = "Post attachment", description = "Upload the attachment of a message, as parameter.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok." + ), + @ApiResponse(responseCode = "404", description = " The identity or the portrait not found")} + ) @Path("posts/{messageKey}/attachments") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @@ -556,6 +660,11 @@ public class ForumWebService { @Operation(summary = "Post attachment", description = "Upload the attachment of a message.") @Path("posts/{messageKey}/attachments") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok." + ), + @ApiResponse(responseCode = "404", description = " The identity or the portrait not found")} + ) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response replyToPostAttachment(@PathParam("messageKey") Long messageKey, @FormParam("filename") String filename, @@ -568,6 +677,11 @@ public class ForumWebService { @PUT @Operation(summary = "Put attachment", description = "Upload the attachment of a message.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Ok." + ), + @ApiResponse(responseCode = "404", description = " The identity or the portrait not found")} + ) @Path("posts/{messageKey}/attachments") @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) diff --git a/src/main/java/org/olat/modules/fo/restapi/MyForumsWebService.java b/src/main/java/org/olat/modules/fo/restapi/MyForumsWebService.java index d25e60c858f..782716d8b46 100644 --- a/src/main/java/org/olat/modules/fo/restapi/MyForumsWebService.java +++ b/src/main/java/org/olat/modules/fo/restapi/MyForumsWebService.java @@ -47,6 +47,7 @@ import javax.ws.rs.core.Response.Status; import org.olat.basesecurity.BaseSecurityManager; import org.olat.basesecurity.OrganisationRoles; import org.olat.collaboration.CollaborationTools; +import org.olat.commons.calendar.restapi.EventVO; import org.olat.core.commons.services.notifications.NotificationsManager; import org.olat.core.commons.services.notifications.Subscriber; import org.olat.core.id.Identity; @@ -69,6 +70,12 @@ import org.olat.restapi.group.LearningGroupWebService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -108,6 +115,7 @@ public class MyForumsWebService { */ @Path("group/{groupKey}") + public ForumWebService getGroupForum(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) { if(groupKey == null) { throw new WebApplicationException( Response.serverError().status(Status.NOT_FOUND).build()); @@ -147,6 +155,19 @@ public class MyForumsWebService { * @return The forums */ @GET + @Operation(summary = "Retrieves a list of forums on a user base.", description = "Retrieves a list of forums on a user base. All forums of groups \n" + + "where the user is participant/tutor + all forums in course where\n" + + "the user is a participant (owner, tutor or participant)") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Request was successful.", + content = { + @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = ForumVO.class))), + @Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = ForumVO.class))) + } + ), + @ApiResponse(responseCode = "401", description = "The roles of the authenticated user are not sufficient."), + @ApiResponse(responseCode = "404", description = "Not found.")} +) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getForums(@PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest) { diff --git a/src/main/java/org/olat/restapi/group/LearningGroupWebService.java b/src/main/java/org/olat/restapi/group/LearningGroupWebService.java index 2c54ab08fe8..85cf2abf5d8 100644 --- a/src/main/java/org/olat/restapi/group/LearningGroupWebService.java +++ b/src/main/java/org/olat/restapi/group/LearningGroupWebService.java @@ -521,6 +521,7 @@ public class LearningGroupWebService { * @return */ @Path("{groupKey}/forum") + public ForumWebService getForum(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) { BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class); BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(groupKey); diff --git a/src/main/java/org/olat/restapi/repository/RepositoryEntriesWebService.java b/src/main/java/org/olat/restapi/repository/RepositoryEntriesWebService.java index f9f838c973f..1869b1c50ef 100644 --- a/src/main/java/org/olat/restapi/repository/RepositoryEntriesWebService.java +++ b/src/main/java/org/olat/restapi/repository/RepositoryEntriesWebService.java @@ -115,7 +115,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; url = "https://github.com/OpenOLAT/OpenOLAT/blob/master/LICENSE" ) ), - servers = { @Server(url = "/restapi") } + servers = { @Server(url = "/restapi"), + @Server(url = "/olat/restapi")} ) @Path("repo/entries") public class RepositoryEntriesWebService { diff --git a/src/main/java/org/olat/restapi/repository/course/CourseAssessmentWebService.java b/src/main/java/org/olat/restapi/repository/course/CourseAssessmentWebService.java index eca87b92539..07d69787791 100644 --- a/src/main/java/org/olat/restapi/repository/course/CourseAssessmentWebService.java +++ b/src/main/java/org/olat/restapi/repository/course/CourseAssessmentWebService.java @@ -87,6 +87,9 @@ import org.olat.restapi.support.vo.AssessableResultsVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; /** @@ -197,6 +200,7 @@ public class CourseAssessmentWebService { @GET @Path("users/{identityKey}") + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response getCourseResultsOf(@PathParam("courseId") Long courseId, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest, @Context Request request) { ICourse course = CoursesWebService.loadCourse(courseId); -- GitLab