Skip to content

Commit

Permalink
Renamed "createdBy" to "owner"
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed Feb 16, 2024
1 parent ced223e commit 1f843b2
Show file tree
Hide file tree
Showing 65 changed files with 446 additions and 446 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,37 @@ protected boolean isOwner(InvocationContext context) {
if (style == AuthorizedStyle.GroupAndArtifact) {
String groupId = getStringParam(context, 0);
String artifactId = getStringParam(context, 1);
return verifyArtifactCreatedBy(groupId, artifactId);
return verifyArtifactOwner(groupId, artifactId);
} else if (style == AuthorizedStyle.GroupOnly && authConfig.ownerOnlyAuthorizationLimitGroupAccess.get()) {
String groupId = getStringParam(context, 0);
return verifyGroupCreatedBy(groupId);
return verifyGroupOwner(groupId);
} else if (style == AuthorizedStyle.ArtifactOnly) {
String artifactId = getStringParam(context, 0);
return verifyArtifactCreatedBy(null, artifactId);
return verifyArtifactOwner(null, artifactId);
} else if (style == AuthorizedStyle.GlobalId) {
long globalId = getLongParam(context, 0);
return verifyArtifactCreatedBy(globalId);
return verifyArtifactOwner(globalId);
} else {
return true;
}
}

private boolean verifyGroupCreatedBy(String groupId) {
private boolean verifyGroupOwner(String groupId) {

Check warning on line 48 in app/src/main/java/io/apicurio/registry/auth/AbstractAccessController.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Boolean method name must start with question word

Boolean method name `verifyGroupOwner` does not start with question word
try {
GroupMetaDataDto dto = storage.getGroupMetaData(groupId);
String createdBy = dto.getCreatedBy();
return createdBy == null || createdBy.equals(securityIdentity.getPrincipal().getName());
String owner = dto.getOwner();
return owner == null || owner.equals(securityIdentity.getPrincipal().getName());
} catch (NotFoundException nfe) {
// If the group is not found, then return true and let the operation proceed.
return true;
}
}

private boolean verifyArtifactCreatedBy(String groupId, String artifactId) {
private boolean verifyArtifactOwner(String groupId, String artifactId) {

Check warning on line 59 in app/src/main/java/io/apicurio/registry/auth/AbstractAccessController.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Boolean method name must start with question word

Boolean method name `verifyArtifactOwner` does not start with question word
try {
ArtifactMetaDataDto dto = storage.getArtifactMetaData(groupId, artifactId, DEFAULT);
String createdBy = dto.getCreatedBy();
return createdBy == null || createdBy.equals(securityIdentity.getPrincipal().getName());
String owner = dto.getOwner();
return owner == null || owner.equals(securityIdentity.getPrincipal().getName());
} catch (NotFoundException nfe) {
// If the artifact is not found, then return true and let the operation proceed
// as normal. The result of which will typically be a 404 response, but sometimes
Expand All @@ -69,11 +69,11 @@ private boolean verifyArtifactCreatedBy(String groupId, String artifactId) {
}
}

private boolean verifyArtifactCreatedBy(long globalId) {
private boolean verifyArtifactOwner(long globalId) {

Check warning on line 72 in app/src/main/java/io/apicurio/registry/auth/AbstractAccessController.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Boolean method name must start with question word

Boolean method name `verifyArtifactOwner` does not start with question word
try {
ArtifactMetaDataDto dto = storage.getArtifactMetaData(globalId);
String createdBy = dto.getCreatedBy();
return createdBy == null || createdBy.equals(securityIdentity.getPrincipal().getName());
String owner = dto.getOwner();
return owner == null || owner.equals(securityIdentity.getPrincipal().getName());
} catch (NotFoundException nfe) {
// If the artifact is not found, then return true and let the operation proceed
// as normal. The result of which will typically be a 404 response, but sometimes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void createGroup(String groupId, SchemaGroup data) {
String user = securityIdentity.getPrincipal().getName();

try {
group.createdBy(user)
group.owner(user)
.createdOn(new Date().getTime());

storage.createGroup(group.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public ArtifactOwner getArtifactOwner(String groupId, String artifactId) {

ArtifactMetaDataDto dto = storage.getArtifactMetaData(defaultGroupIdToNull(groupId), artifactId);
ArtifactOwner owner = new ArtifactOwner();
owner.setOwner(dto.getCreatedBy());
owner.setOwner(dto.getOwner());
return owner;
}

Expand Down Expand Up @@ -290,7 +290,7 @@ public GroupMetaData createGroup(CreateGroupMetaData data) {
.labels(data.getProperties());

String user = securityIdentity.getPrincipal().getName();
group.createdBy(user).createdOn(new Date().getTime());
group.owner(user).createdOn(new Date().getTime());

storage.createGroup(group.build());

Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/io/apicurio/registry/rest/v2/V2ApiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private V2ApiUtil() {
public static ArtifactMetaData dtoToMetaData(String groupId, String artifactId,
String artifactType, ArtifactMetaDataDto dto) {
ArtifactMetaData metaData = new ArtifactMetaData();
metaData.setCreatedBy(dto.getCreatedBy());
metaData.setCreatedBy(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setDescription(dto.getDescription());
if (groupId != null) {
Expand Down Expand Up @@ -148,12 +148,12 @@ public static Map<String, String> toV3Labels(List<String> v2Labels, Map<String,
public static final ArtifactMetaData dtoToMetaData(String groupId, String artifactId, String artifactType,
ArtifactVersionMetaDataDto dto) {
ArtifactMetaData metaData = new ArtifactMetaData();
metaData.setCreatedBy(dto.getCreatedBy());
metaData.setCreatedBy(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setDescription(dto.getDescription());
metaData.setGroupId(groupId);
metaData.setId(artifactId);
metaData.setModifiedBy(dto.getCreatedBy());
metaData.setModifiedBy(dto.getOwner());
metaData.setModifiedOn(new Date(dto.getCreatedOn()));
metaData.setName(dto.getName());
if (artifactType != null) {
Expand Down Expand Up @@ -184,7 +184,7 @@ public static final VersionMetaData dtoToVersionMetaData(String groupId, String
VersionMetaData metaData = new VersionMetaData();
metaData.setGroupId(groupId);
metaData.setId(artifactId);
metaData.setCreatedBy(dto.getCreatedBy());
metaData.setCreatedBy(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setDescription(dto.getDescription());
metaData.setName(dto.getName());
Expand All @@ -210,7 +210,7 @@ public static final VersionMetaData dtoToVersionMetaData(String groupId, String
VersionMetaData metaData = new VersionMetaData();
metaData.setGroupId(groupId);
metaData.setId(artifactId);
metaData.setCreatedBy(dto.getCreatedBy());
metaData.setCreatedBy(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setDescription(dto.getDescription());
metaData.setName(dto.getName());
Expand Down Expand Up @@ -266,7 +266,7 @@ public static ArtifactSearchResults dtoToSearchResults(ArtifactSearchResultsDto
results.setArtifacts(new ArrayList<>(dto.getArtifacts().size()));
dto.getArtifacts().forEach(artifact -> {
SearchedArtifact sa = new SearchedArtifact();
sa.setCreatedBy(artifact.getCreatedBy());
sa.setCreatedBy(artifact.getOwner());
sa.setCreatedOn(artifact.getCreatedOn());
sa.setDescription(artifact.getDescription());
sa.setId(artifact.getId());
Expand All @@ -287,7 +287,7 @@ public static GroupSearchResults dtoToSearchResults(GroupSearchResultsDto dto) {
results.setGroups(new ArrayList<>(dto.getGroups().size()));
dto.getGroups().forEach(group -> {
SearchedGroup sg = new SearchedGroup();
sg.setCreatedBy(group.getCreatedBy());
sg.setCreatedBy(group.getOwner());
sg.setCreatedOn(group.getCreatedOn());
sg.setDescription(group.getDescription());
sg.setId(group.getId());
Expand All @@ -304,7 +304,7 @@ public static VersionSearchResults dtoToSearchResults(VersionSearchResultsDto dt
results.setVersions(new ArrayList<>(dto.getVersions().size()));
dto.getVersions().forEach(version -> {
SearchedVersion sv = new SearchedVersion();
sv.setCreatedBy(version.getCreatedBy());
sv.setCreatedBy(version.getOwner());
sv.setCreatedOn(version.getCreatedOn());
sv.setDescription(version.getDescription());
sv.setGlobalId(version.getGlobalId());
Expand Down Expand Up @@ -340,7 +340,7 @@ public static GroupMetaData groupDtoToGroup(GroupMetaDataDto dto) {
GroupMetaData group = new GroupMetaData();
group.setId(dto.getGroupId());
group.setDescription(dto.getDescription());
group.setCreatedBy(dto.getCreatedBy());
group.setCreatedBy(dto.getOwner());
group.setModifiedBy(dto.getModifiedBy());
group.setCreatedOn(new Date(dto.getCreatedOn()));
group.setModifiedOn(new Date(dto.getModifiedOn()));
Expand All @@ -351,7 +351,7 @@ public static GroupMetaData groupDtoToGroup(GroupMetaDataDto dto) {
public static Comment commentDtoToComment(CommentDto dto) {
return Comment.builder()
.commentId(dto.getCommentId())
.createdBy(dto.getCreatedBy())
.createdBy(dto.getOwner())
.createdOn(new Date(dto.getCreatedOn()))
.value(dto.getValue())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public ArtifactOwner getArtifactOwner(String groupId, String artifactId) {

ArtifactMetaDataDto dto = storage.getArtifactMetaData(new GroupId(groupId).getRawGroupIdWithNull(), artifactId);
ArtifactOwner owner = new ArtifactOwner();
owner.setOwner(dto.getCreatedBy());
owner.setOwner(dto.getOwner());
return owner;
}

Expand Down Expand Up @@ -312,7 +312,7 @@ public GroupMetaData createGroup(CreateGroupMetaData data) {
.labels(data.getLabels());

String user = securityIdentity.getPrincipal().getName();
group.createdBy(user).createdOn(new Date().getTime());
group.owner(user).createdOn(new Date().getTime());

storage.createGroup(group.build());

Expand Down
22 changes: 11 additions & 11 deletions app/src/main/java/io/apicurio/registry/rest/v3/V3ApiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private V3ApiUtil() {
public static ArtifactMetaData dtoToMetaData(String groupId, String artifactId,
String artifactType, ArtifactMetaDataDto dto) {
ArtifactMetaData metaData = new ArtifactMetaData();
metaData.setCreatedBy(dto.getCreatedBy());
metaData.setOwner(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setDescription(dto.getDescription());
if (groupId != null) {
Expand Down Expand Up @@ -93,12 +93,12 @@ public static ArtifactMetaData dtoToMetaData(String groupId, String artifactId,
public static final ArtifactMetaData dtoToMetaData(String groupId, String artifactId, String artifactType,
ArtifactVersionMetaDataDto dto) {
ArtifactMetaData metaData = new ArtifactMetaData();
metaData.setCreatedBy(dto.getCreatedBy());
metaData.setOwner(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setDescription(dto.getDescription());
metaData.setGroupId(groupId);
metaData.setId(artifactId);
metaData.setModifiedBy(dto.getCreatedBy());
metaData.setModifiedBy(dto.getOwner());
metaData.setModifiedOn(new Date(dto.getCreatedOn()));
metaData.setName(dto.getName());
if (artifactType != null) {
Expand Down Expand Up @@ -128,7 +128,7 @@ public static final VersionMetaData dtoToVersionMetaData(String groupId, String
VersionMetaData metaData = new VersionMetaData();
metaData.setGroupId(groupId);
metaData.setId(artifactId);
metaData.setCreatedBy(dto.getCreatedBy());
metaData.setOwner(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setDescription(dto.getDescription());
metaData.setName(dto.getName());
Expand All @@ -154,7 +154,7 @@ public static final VersionMetaData dtoToVersionMetaData(String groupId, String
VersionMetaData metaData = new VersionMetaData();
metaData.setGroupId(groupId);
metaData.setId(artifactId);
metaData.setCreatedBy(amd.getCreatedBy());
metaData.setOwner(amd.getOwner());
metaData.setCreatedOn(amd.getCreatedOn());
metaData.setDescription(amd.getDescription());
metaData.setName(amd.getName());
Expand All @@ -178,7 +178,7 @@ public static final VersionMetaData dtoToVersionMetaData(String groupId, String
VersionMetaData metaData = new VersionMetaData();
metaData.setGroupId(groupId);
metaData.setId(artifactId);
metaData.setCreatedBy(dto.getCreatedBy());
metaData.setOwner(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setDescription(dto.getDescription());
metaData.setName(dto.getName());
Expand Down Expand Up @@ -233,7 +233,7 @@ public static ArtifactSearchResults dtoToSearchResults(ArtifactSearchResultsDto
results.setArtifacts(new ArrayList<>(dto.getArtifacts().size()));
dto.getArtifacts().forEach(artifact -> {
SearchedArtifact sa = new SearchedArtifact();
sa.setCreatedBy(artifact.getCreatedBy());
sa.setOwner(artifact.getOwner());
sa.setCreatedOn(artifact.getCreatedOn());
sa.setDescription(artifact.getDescription());
sa.setId(artifact.getId());
Expand All @@ -254,7 +254,7 @@ public static GroupSearchResults dtoToSearchResults(GroupSearchResultsDto dto) {
results.setGroups(new ArrayList<>(dto.getGroups().size()));
dto.getGroups().forEach(group -> {
SearchedGroup sg = new SearchedGroup();
sg.setCreatedBy(group.getCreatedBy());
sg.setOwner(group.getOwner());
sg.setCreatedOn(group.getCreatedOn());
sg.setDescription(group.getDescription());
sg.setId(group.getId());
Expand All @@ -271,7 +271,7 @@ public static VersionSearchResults dtoToSearchResults(VersionSearchResultsDto dt
results.setVersions(new ArrayList<>(dto.getVersions().size()));
dto.getVersions().forEach(version -> {
SearchedVersion sv = new SearchedVersion();
sv.setCreatedBy(version.getCreatedBy());
sv.setOwner(version.getOwner());
sv.setCreatedOn(version.getCreatedOn());
sv.setDescription(version.getDescription());
sv.setGlobalId(version.getGlobalId());
Expand Down Expand Up @@ -307,7 +307,7 @@ public static GroupMetaData groupDtoToGroup(GroupMetaDataDto dto) {
GroupMetaData group = new GroupMetaData();
group.setId(dto.getGroupId());
group.setDescription(dto.getDescription());
group.setCreatedBy(dto.getCreatedBy());
group.setOwner(dto.getOwner());
group.setModifiedBy(dto.getModifiedBy());
group.setCreatedOn(new Date(dto.getCreatedOn()));
group.setModifiedOn(new Date(dto.getModifiedOn()));
Expand All @@ -318,7 +318,7 @@ public static GroupMetaData groupDtoToGroup(GroupMetaDataDto dto) {
public static Comment commentDtoToComment(CommentDto dto) {
return Comment.builder()
.commentId(dto.getCommentId())
.createdBy(dto.getCreatedBy())
.owner(dto.getOwner())
.createdOn(new Date(dto.getCreatedOn()))
.value(dto.getValue())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ void updateArtifactRule(String groupId, String artifactId, RuleType rule, RuleCo


CommentDto createArtifactVersionCommentRaw(String groupId, String artifactId, String version, IdGenerator commentId,
String createdBy, Date createdOn, String value);
String owner, Date createdOn, String value);


void resetGlobalId();
Expand Down Expand Up @@ -900,13 +900,13 @@ CommentDto createArtifactVersionCommentRaw(String groupId, String artifactId, St


ArtifactMetaDataDto updateArtifactWithMetadata(String groupId, String artifactId, String version,
String artifactType, String contentHash, String createdBy, Date createdOn,
String artifactType, String contentHash, String owner, Date createdOn,
EditableArtifactMetaDataDto metaData,
IdGenerator globalIdGenerator);


ArtifactMetaDataDto createArtifactWithMetadata(String groupId, String artifactId, String version,
String artifactType, String contentHash, String createdBy,
String artifactType, String contentHash, String owner,
Date createdOn, EditableArtifactMetaDataDto metaData, IdGenerator globalIdGenerator)
throws ArtifactNotFoundException, RegistryStorageException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ public void deleteAllExpiredDownloads() throws RegistryStorageException {

@Override
public CommentDto createArtifactVersionCommentRaw(String groupId, String artifactId, String version,
IdGenerator commentId, String createdBy, Date createdOn, String value) {
IdGenerator commentId, String owner, Date createdOn, String value) {
checkReadOnly();
return delegate.createArtifactVersionCommentRaw(groupId, artifactId, version, commentId, createdBy, createdOn, value);
return delegate.createArtifactVersionCommentRaw(groupId, artifactId, version, commentId, owner, createdOn, value);
}


Expand Down Expand Up @@ -449,23 +449,23 @@ public void updateContentCanonicalHash(String newCanonicalHash, long contentId,

@Override
public ArtifactMetaDataDto updateArtifactWithMetadata(String groupId, String artifactId, String version,
String artifactType, String contentHash, String createdBy,
String artifactType, String contentHash, String owner,
Date createdOn, EditableArtifactMetaDataDto metaData,
IdGenerator globalIdGenerator) {
checkReadOnly();
return delegate.updateArtifactWithMetadata(groupId, artifactId, version, artifactType, contentHash, createdBy,
return delegate.updateArtifactWithMetadata(groupId, artifactId, version, artifactType, contentHash, owner,
createdOn, metaData, globalIdGenerator);
}


@Override
public ArtifactMetaDataDto createArtifactWithMetadata(String groupId, String artifactId, String version,
String artifactType, String contentHash, String createdBy,
String artifactType, String contentHash, String owner,
Date createdOn, EditableArtifactMetaDataDto metaData,
IdGenerator globalIdGenerator)
throws ArtifactNotFoundException, RegistryStorageException {
checkReadOnly();
return delegate.createArtifactWithMetadata(groupId, artifactId, version, artifactType, contentHash, createdBy,
return delegate.createArtifactWithMetadata(groupId, artifactId, version, artifactType, contentHash, owner,
createdOn, metaData, globalIdGenerator);
}

Expand Down
Loading

0 comments on commit 1f843b2

Please sign in to comment.