Skip to content

Commit e13287d

Browse files
committed
fixup! Add playlist feature
1 parent a409af3 commit e13287d

22 files changed

+77
-47
lines changed

modules/graphql/src/main/java/org/opencastproject/graphql/command/DeletePlaylistCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.opencastproject.graphql.exception.GraphQLUnauthorizedException;
2525
import org.opencastproject.graphql.execution.context.OpencastContext;
2626
import org.opencastproject.graphql.execution.context.OpencastContextManager;
27-
import org.opencastproject.graphql.playlist.GqlDeletePlaylistPayload;
27+
import org.opencastproject.graphql.playlist.type.output.GqlDeletePlaylistPayload;
2828
import org.opencastproject.playlists.PlaylistService;
2929
import org.opencastproject.security.api.UnauthorizedException;
3030
import org.opencastproject.util.NotFoundException;

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/PlaylistCurrentUserExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
import graphql.schema.DataFetchingEnvironment;
3535

3636
@GraphQLTypeExtension(GqlCurrentUser.class)
37-
public class PlaylistUserExtension {
37+
public class PlaylistCurrentUserExtension {
3838

3939
private final GqlCurrentUser currentUser;
4040

41-
public PlaylistUserExtension(GqlCurrentUser currentUser) {
41+
public PlaylistCurrentUserExtension(GqlCurrentUser currentUser) {
4242
this.currentUser = currentUser;
4343
}
4444

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/PlaylistGraphQLProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
package org.opencastproject.graphql.playlist;
2323

24+
import org.opencastproject.graphql.playlist.type.output.GqlEventPlaylistEntry;
25+
import org.opencastproject.graphql.playlist.type.output.GqlInaccessiblePlaylistEntry;
2426
import org.opencastproject.graphql.provider.GraphQLAdditionalTypeProvider;
2527

2628
import org.osgi.service.component.annotations.Component;

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/PlaylistMutationExtension.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121

2222
package org.opencastproject.graphql.playlist;
2323

24-
import org.opencastproject.graphql.command.CreatePlaylistCommand;
24+
import org.opencastproject.graphql.playlist.command.CreatePlaylistCommand;
2525
import org.opencastproject.graphql.command.DeletePlaylistCommand;
26-
import org.opencastproject.graphql.command.UpdatePlaylistCommand;
26+
import org.opencastproject.graphql.playlist.command.UpdatePlaylistCommand;
2727
import org.opencastproject.graphql.directive.RolesAllowed;
28+
import org.opencastproject.graphql.playlist.type.output.GqlDeletePlaylistPayload;
29+
import org.opencastproject.graphql.playlist.type.input.PlaylistEntriesInput;
30+
import org.opencastproject.graphql.playlist.type.input.PlaylistMetadataInput;
31+
import org.opencastproject.graphql.playlist.type.output.GqlPlaylist;
2832
import org.opencastproject.graphql.type.input.AccessControlListInput;
2933
import org.opencastproject.graphql.type.input.Mutation;
3034

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/PlaylistQueryExtension.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
package org.opencastproject.graphql.playlist;
2323

24-
import org.opencastproject.graphql.datafetcher.playlist.PlaylistDataFetcher;
25-
import org.opencastproject.graphql.datafetcher.playlist.PlaylistOffsetDataFetcher;
24+
import org.opencastproject.graphql.playlist.datafetcher.PlaylistDataFetcher;
25+
import org.opencastproject.graphql.playlist.datafetcher.PlaylistOffsetDataFetcher;
26+
import org.opencastproject.graphql.playlist.type.output.GqlPlaylist;
27+
import org.opencastproject.graphql.playlist.type.output.GqlPlaylistList;
2628
import org.opencastproject.graphql.type.input.PlaylistOrderByInput;
2729
import org.opencastproject.graphql.type.output.Query;
2830

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/command/CreatePlaylistCommand.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
*
2020
*/
2121

22-
package org.opencastproject.graphql.command;
22+
package org.opencastproject.graphql.playlist.command;
2323

2424
import org.opencastproject.authorization.xacml.manager.api.AclService;
2525
import org.opencastproject.authorization.xacml.manager.api.AclServiceFactory;
26+
import org.opencastproject.graphql.command.AbstractCommand;
2627
import org.opencastproject.graphql.exception.GraphQLRuntimeException;
2728
import org.opencastproject.graphql.exception.GraphQLUnauthorizedException;
2829
import org.opencastproject.graphql.execution.context.OpencastContext;
2930
import org.opencastproject.graphql.execution.context.OpencastContextManager;
30-
import org.opencastproject.graphql.playlist.GqlPlaylist;
31-
import org.opencastproject.graphql.playlist.PlaylistEntriesInput;
32-
import org.opencastproject.graphql.playlist.PlaylistMetadataInput;
31+
import org.opencastproject.graphql.playlist.type.output.GqlPlaylist;
32+
import org.opencastproject.graphql.playlist.type.input.PlaylistEntriesInput;
33+
import org.opencastproject.graphql.playlist.type.input.PlaylistMetadataInput;
3334
import org.opencastproject.graphql.type.input.AccessControlListInput;
3435
import org.opencastproject.graphql.util.GraphQLObjectMapper;
3536
import org.opencastproject.playlists.Playlist;
@@ -67,7 +68,6 @@ public GqlPlaylist execute() {
6768
final PlaylistService playlistService = context.getService(PlaylistService.class);
6869
final SecurityService securityService = context.getService(SecurityService.class);
6970
try {
70-
// read arguments from environment when present, otherwise fall back to builder values
7171
final Object metadataArg = environment.getArgument("metadata");
7272
final PlaylistMetadataInput metadata = metadataArg == null
7373
? metadataInput
@@ -124,7 +124,6 @@ public GqlPlaylist execute() {
124124
}
125125
playlist.setAccessControlEntries(aceList);
126126

127-
// Persist
128127
playlist = playlistService.update(playlist);
129128

130129
return new GqlPlaylist(playlist);

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/command/UpdatePlaylistCommand.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919
*
2020
*/
2121

22-
package org.opencastproject.graphql.command;
22+
package org.opencastproject.graphql.playlist.command;
2323

2424
import org.opencastproject.authorization.xacml.manager.api.AclService;
2525
import org.opencastproject.authorization.xacml.manager.api.AclServiceFactory;
26+
import org.opencastproject.graphql.command.AbstractCommand;
2627
import org.opencastproject.graphql.exception.GraphQLNotFoundException;
2728
import org.opencastproject.graphql.exception.GraphQLRuntimeException;
2829
import org.opencastproject.graphql.exception.GraphQLUnauthorizedException;
2930
import org.opencastproject.graphql.execution.context.OpencastContext;
3031
import org.opencastproject.graphql.execution.context.OpencastContextManager;
31-
import org.opencastproject.graphql.playlist.GqlPlaylist;
32-
import org.opencastproject.graphql.playlist.PlaylistEntriesInput;
33-
import org.opencastproject.graphql.playlist.PlaylistMetadataInput;
32+
import org.opencastproject.graphql.playlist.type.output.GqlPlaylist;
33+
import org.opencastproject.graphql.playlist.type.input.PlaylistEntriesInput;
34+
import org.opencastproject.graphql.playlist.type.input.PlaylistMetadataInput;
3435
import org.opencastproject.graphql.type.input.AccessControlListInput;
3536
import org.opencastproject.graphql.util.GraphQLObjectMapper;
3637
import org.opencastproject.playlists.Playlist;
@@ -94,11 +95,8 @@ public GqlPlaylist execute() {
9495
if (entries != null && entries.getEntries() != null) {
9596
List<PlaylistEntry> playlistEntries = new ArrayList<>();
9697
for (var entryInput : entries.getEntries()) {
97-
PlaylistEntryType type = PlaylistEntryType.EVENT;
98-
if (entryInput != null && entryInput.getType() != null) {
99-
type = entryInput.getType().getType();
100-
}
101-
PlaylistEntry pe = new PlaylistEntry(entryInput == null ? null : entryInput.getContentId(), type);
98+
PlaylistEntryType type = entryInput.getType().getType();
99+
PlaylistEntry pe = new PlaylistEntry(entryInput.getContentId(), type);
102100
playlistEntries.add(pe);
103101
}
104102
playlist.setEntries(playlistEntries);

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/datafetcher/PlaylistDataFetcher.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
*
2020
*/
2121

22-
package org.opencastproject.graphql.datafetcher.playlist;
22+
package org.opencastproject.graphql.playlist.datafetcher;
2323

2424
import org.opencastproject.graphql.datafetcher.ContextDataFetcher;
2525
import org.opencastproject.graphql.exception.GraphQLRuntimeException;
2626
import org.opencastproject.graphql.exception.OpencastErrorType;
2727
import org.opencastproject.graphql.execution.context.OpencastContext;
28-
import org.opencastproject.graphql.playlist.GqlPlaylist;
28+
import org.opencastproject.graphql.playlist.type.output.GqlPlaylist;
2929
import org.opencastproject.playlists.Playlist;
3030
import org.opencastproject.playlists.PlaylistService;
3131
import org.opencastproject.security.api.UnauthorizedException;
@@ -53,11 +53,9 @@ public GqlPlaylist get(OpencastContext opencastContext, DataFetchingEnvironment
5353
if (playlist == null) {
5454
return null;
5555
}
56-
// enrich if available
5756
try {
5857
playlist = playlistService.enrich(playlist).toPlaylist();
5958
} catch (Throwable ignored) {
60-
// If enrich is not available or fails, fall back to original playlist
6159
}
6260
return new GqlPlaylist(playlist);
6361
} catch (NotFoundException e) {

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/datafetcher/PlaylistOffsetDataFetcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
*
2020
*/
2121

22-
package org.opencastproject.graphql.datafetcher.playlist;
22+
package org.opencastproject.graphql.playlist.datafetcher;
2323

2424
import org.opencastproject.graphql.datafetcher.ElasticsearchDataFetcher;
2525
import org.opencastproject.graphql.execution.context.OpencastContext;
26-
import org.opencastproject.graphql.playlist.GqlPlaylistList;
26+
import org.opencastproject.graphql.playlist.type.output.GqlPlaylistList;
2727
import org.opencastproject.playlists.Playlist;
2828
import org.opencastproject.playlists.PlaylistAccessControlEntry;
2929
import org.opencastproject.playlists.PlaylistService;

modules/graphql/src/main/java/org/opencastproject/graphql/playlist/type/GqlPlaylistEntryType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
*
2020
*/
2121

22-
package org.opencastproject.graphql.playlist;
22+
package org.opencastproject.graphql.playlist.type;
2323

2424
import org.opencastproject.playlists.PlaylistEntryType;
2525

2626
import graphql.annotations.annotationTypes.GraphQLDescription;
2727
import graphql.annotations.annotationTypes.GraphQLName;
2828

2929
@GraphQLName(GqlPlaylistEntryType.TYPE_NAME)
30-
@GraphQLDescription("The direction of the order")
30+
@GraphQLDescription("The type of a playlist entry.")
3131
public enum GqlPlaylistEntryType {
3232
EVENT(PlaylistEntryType.EVENT),
3333
INACCESSIBLE(PlaylistEntryType.INACCESSIBLE);

0 commit comments

Comments
 (0)