22
22
import io .apicurio .registry .rest .v3 .beans .ArtifactMetaData ;
23
23
import io .apicurio .registry .rest .v3 .beans .ArtifactReference ;
24
24
import io .apicurio .registry .rest .v3 .beans .ArtifactSearchResults ;
25
+ import io .apicurio .registry .rest .v3 .beans .ArtifactSortBy ;
25
26
import io .apicurio .registry .rest .v3 .beans .Comment ;
26
27
import io .apicurio .registry .rest .v3 .beans .CreateArtifact ;
27
28
import io .apicurio .registry .rest .v3 .beans .CreateArtifactResponse ;
32
33
import io .apicurio .registry .rest .v3 .beans .EditableVersionMetaData ;
33
34
import io .apicurio .registry .rest .v3 .beans .GroupMetaData ;
34
35
import io .apicurio .registry .rest .v3 .beans .GroupSearchResults ;
36
+ import io .apicurio .registry .rest .v3 .beans .GroupSortBy ;
35
37
import io .apicurio .registry .rest .v3 .beans .HandleReferencesType ;
36
38
import io .apicurio .registry .rest .v3 .beans .IfArtifactExists ;
37
- import io .apicurio .registry .rest .v3 .beans .IfVersionExists ;
38
39
import io .apicurio .registry .rest .v3 .beans .NewComment ;
39
40
import io .apicurio .registry .rest .v3 .beans .Rule ;
40
- import io .apicurio .registry .rest .v3 .beans .SortBy ;
41
41
import io .apicurio .registry .rest .v3 .beans .SortOrder ;
42
42
import io .apicurio .registry .rest .v3 .beans .VersionContent ;
43
43
import io .apicurio .registry .rest .v3 .beans .VersionMetaData ;
44
44
import io .apicurio .registry .rest .v3 .beans .VersionSearchResults ;
45
+ import io .apicurio .registry .rest .v3 .beans .VersionSortBy ;
45
46
import io .apicurio .registry .rest .v3 .shared .CommonResourceOperations ;
46
47
import io .apicurio .registry .rules .RuleApplicationType ;
47
48
import io .apicurio .registry .rules .RulesService ;
@@ -248,9 +249,9 @@ public void updateGroupById(String groupId, EditableGroupMetaData data) {
248
249
249
250
@ Override
250
251
@ Authorized (style = AuthorizedStyle .None , level = AuthorizedLevel .Read )
251
- public GroupSearchResults listGroups (BigInteger limit , BigInteger offset , SortOrder order , SortBy orderby ) {
252
+ public GroupSearchResults listGroups (BigInteger limit , BigInteger offset , SortOrder order , GroupSortBy orderby ) {
252
253
if (orderby == null ) {
253
- orderby = SortBy . name ;
254
+ orderby = GroupSortBy . groupId ;
254
255
}
255
256
if (offset == null ) {
256
257
offset = BigInteger .valueOf (0 );
@@ -272,7 +273,7 @@ public GroupSearchResults listGroups(BigInteger limit, BigInteger offset, SortOr
272
273
@ Authorized (style = AuthorizedStyle .None , level = AuthorizedLevel .Write )
273
274
public GroupMetaData createGroup (CreateGroup data ) {
274
275
GroupMetaDataDto .GroupMetaDataDtoBuilder group = GroupMetaDataDto .builder ()
275
- .groupId (data .getId ())
276
+ .groupId (data .getGroupId ())
276
277
.description (data .getDescription ())
277
278
.labels (data .getLabels ());
278
279
@@ -281,7 +282,7 @@ public GroupMetaData createGroup(CreateGroup data) {
281
282
282
283
storage .createGroup (group .build ());
283
284
284
- return V3ApiUtil .groupDtoToGroup (storage .getGroupMetaData (data .getId ()));
285
+ return V3ApiUtil .groupDtoToGroup (storage .getGroupMetaData (data .getGroupId ()));
285
286
}
286
287
287
288
@ Override
@@ -614,11 +615,11 @@ public void updateArtifactVersionComment(String groupId, String artifactId, Stri
614
615
@ Override
615
616
@ Authorized (style = AuthorizedStyle .GroupOnly , level = AuthorizedLevel .Read )
616
617
public ArtifactSearchResults listArtifactsInGroup (String groupId , BigInteger limit , BigInteger offset ,
617
- SortOrder order , SortBy orderby ) {
618
+ SortOrder order , ArtifactSortBy orderby ) {
618
619
requireParameter ("groupId" , groupId );
619
620
620
621
if (orderby == null ) {
621
- orderby = SortBy .name ;
622
+ orderby = ArtifactSortBy .name ;
622
623
}
623
624
if (offset == null ) {
624
625
offset = BigInteger .valueOf (0 );
@@ -770,28 +771,34 @@ public CreateArtifactResponse createArtifact(String groupId, IfArtifactExists if
770
771
}
771
772
}
772
773
773
-
774
774
@ Override
775
775
@ Authorized (style = AuthorizedStyle .GroupAndArtifact , level = AuthorizedLevel .Read )
776
- public VersionSearchResults listArtifactVersions (String groupId , String artifactId , BigInteger offset , BigInteger limit ) {
776
+ public VersionSearchResults listArtifactVersions (String groupId , String artifactId , BigInteger offset ,
777
+ BigInteger limit , SortOrder order , VersionSortBy orderby ) {
777
778
requireParameter ("groupId" , groupId );
778
779
requireParameter ("artifactId" , artifactId );
779
-
780
+ if (orderby == null ) {
781
+ orderby = VersionSortBy .createdOn ;
782
+ }
780
783
if (offset == null ) {
781
784
offset = BigInteger .valueOf (0 );
782
785
}
783
786
if (limit == null ) {
784
787
limit = BigInteger .valueOf (20 );
785
788
}
786
789
787
- VersionSearchResultsDto resultsDto = storage .searchVersions (new GroupId (groupId ).getRawGroupIdWithNull (), artifactId , offset .intValue (), limit .intValue ());
790
+ final OrderBy oBy = OrderBy .valueOf (orderby .name ());
791
+ final OrderDirection oDir = order == null || order == SortOrder .desc ? OrderDirection .asc : OrderDirection .desc ;
792
+
793
+ VersionSearchResultsDto resultsDto = storage .searchVersions (new GroupId (groupId ).getRawGroupIdWithNull (),
794
+ artifactId , oBy , oDir , offset .intValue (), limit .intValue ());
788
795
return V3ApiUtil .dtoToSearchResults (resultsDto );
789
796
}
790
797
791
798
@ Override
792
- @ Audited (extractParameters = {"0" , KEY_GROUP_ID , "1" , KEY_ARTIFACT_ID , "2" , KEY_IF_EXISTS })
799
+ @ Audited (extractParameters = {"0" , KEY_GROUP_ID , "1" , KEY_ARTIFACT_ID })
793
800
@ Authorized (style = AuthorizedStyle .GroupAndArtifact , level = AuthorizedLevel .Write )
794
- public VersionMetaData createArtifactVersion (String groupId , String artifactId , IfVersionExists ifExists , CreateVersion data ) {
801
+ public VersionMetaData createArtifactVersion (String groupId , String artifactId , CreateVersion data ) {
795
802
requireParameter ("content" , data .getContent ());
796
803
requireParameter ("groupId" , groupId );
797
804
requireParameter ("artifactId" , artifactId );
0 commit comments