@@ -1098,6 +1098,8 @@ private ArtifactMetaData createArtifactWithRefs(String groupId, String xRegistry
1098
1098
1099
1099
String ct = getContentType ();
1100
1100
try {
1101
+
1102
+ String owner = securityIdentity .getPrincipal ().getName ();
1101
1103
String artifactId = xRegistryArtifactId ;
1102
1104
1103
1105
if (artifactId == null || artifactId .trim ().isEmpty ()) {
@@ -1140,7 +1142,7 @@ private ArtifactMetaData createArtifactWithRefs(String groupId, String xRegistry
1140
1142
1141
1143
Pair <ArtifactMetaDataDto , ArtifactVersionMetaDataDto > createResult = storage .createArtifact (
1142
1144
defaultGroupIdToNull (groupId ), artifactId , artifactType , metaData , xRegistryVersion ,
1143
- contentDto , versionMetaData , List .of (), false , false );
1145
+ contentDto , versionMetaData , List .of (), false , false , owner );
1144
1146
1145
1147
return V2ApiUtil .dtoToMetaData (groupId , artifactId , artifactType , createResult .getRight ());
1146
1148
} catch (ArtifactAlreadyExistsException ex ) {
@@ -1258,6 +1260,8 @@ private VersionMetaData createArtifactVersionWithRefs(String groupId, String art
1258
1260
final Map <String , TypedContent > resolvedReferences = RegistryContentUtils
1259
1261
.recursivelyResolveReferences (referencesAsDtos , storage ::getContentByReference );
1260
1262
1263
+ final String owner = securityIdentity .getPrincipal ().getName ();
1264
+
1261
1265
String artifactType = lookupArtifactType (groupId , artifactId );
1262
1266
TypedContent typedContent = TypedContent .create (content , ct );
1263
1267
rulesService .applyRules (defaultGroupIdToNull (groupId ), artifactId , artifactType , typedContent ,
@@ -1266,7 +1270,8 @@ private VersionMetaData createArtifactVersionWithRefs(String groupId, String art
1266
1270
ContentWrapperDto contentDto = ContentWrapperDto .builder ().content (content ).contentType (ct )
1267
1271
.references (referencesAsDtos ).build ();
1268
1272
ArtifactVersionMetaDataDto vmdDto = storage .createArtifactVersion (defaultGroupIdToNull (groupId ),
1269
- artifactId , xRegistryVersion , artifactType , contentDto , metaData , List .of (), false , false );
1273
+ artifactId , xRegistryVersion , artifactType , contentDto , metaData , List .of (), false , false ,
1274
+ owner );
1270
1275
return V2ApiUtil .dtoToVersionMetaData (defaultGroupIdToNull (groupId ), artifactId , artifactType ,
1271
1276
vmdDto );
1272
1277
}
@@ -1366,7 +1371,8 @@ private ArtifactMetaData handleIfExistsReturnOrUpdate(String groupId, String art
1366
1371
content , contentType , references );
1367
1372
}
1368
1373
1369
- private ArtifactMetaData updateArtifactInternal (String groupId , String artifactId , String version ,
1374
+ @ Authorized (style = AuthorizedStyle .GroupAndArtifact , level = AuthorizedLevel .Write )
1375
+ protected ArtifactMetaData updateArtifactInternal (String groupId , String artifactId , String version ,
1370
1376
String name , String description , ContentHandle content , String contentType ,
1371
1377
List <ArtifactReference > references ) {
1372
1378
@@ -1396,13 +1402,16 @@ private ArtifactMetaData updateArtifactInternal(String groupId, String artifactI
1396
1402
if (description != null && description .trim ().isEmpty ()) {
1397
1403
artifactMD .setDescription (description );
1398
1404
}
1405
+
1406
+ final String owner = securityIdentity .getPrincipal ().getName ();
1407
+
1399
1408
EditableVersionMetaDataDto metaData = EditableVersionMetaDataDto .builder ().name (artifactMD .getName ())
1400
1409
.description (artifactMD .getDescription ()).labels (artifactMD .getLabels ()).build ();
1401
1410
1402
1411
ContentWrapperDto contentDto = ContentWrapperDto .builder ().content (content ).contentType (contentType )
1403
1412
.references (referencesAsDtos ).build ();
1404
1413
ArtifactVersionMetaDataDto dto = storage .createArtifactVersion (defaultGroupIdToNull (groupId ),
1405
- artifactId , version , artifactType , contentDto , metaData , List .of (), false , false );
1414
+ artifactId , version , artifactType , contentDto , metaData , List .of (), false , false , owner );
1406
1415
1407
1416
// Note: if the version was created, we need to update the artifact metadata as well, because
1408
1417
// those are the semantics of the v2 API. :(
0 commit comments