Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update roles for icd_edit and fixed some serialization issues for Use… #27

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<dependency>
<groupId>edu.stanford.protege</groupId>
<artifactId>webprotege-backend-api</artifactId>
<version>1.0.24-WHO</version>
<version>1.0.25-WHO</version>
</dependency>
<dependency>
<groupId>edu.stanford.protege</groupId>
Expand All @@ -101,7 +101,7 @@
<dependency>
<groupId>edu.stanford.protege</groupId>
<artifactId>webprotege-ipc</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ public enum BuiltInRole {
DELETE_DATATYPE,
REVERT_CHANGES),

ICD_PROJECT_EDITOR(OBJECT_COMMENTER,
EDIT_ONTOLOGY,
EDIT_ONTOLOGY_ANNOTATIONS,
CREATE_CLASS,
MERGE_ENTITIES,
CREATE_PROPERTY,
CREATE_INDIVIDUAL,
CREATE_DATATYPE,
REVERT_CHANGES),

LAYOUT_EDITOR(ADD_OR_REMOVE_PERSPECTIVE,
ADD_OR_REMOVE_VIEW),

Expand All @@ -113,6 +123,8 @@ public enum BuiltInRole {

CAN_EDIT(PROJECT_EDITOR, CAN_COMMENT),

ICD_CAN_EDIT(ICD_PROJECT_EDITOR, CAN_COMMENT),

CAN_MANAGE(CAN_EDIT, PROJECT_MANAGER, ISSUE_MANAGER)

;
Expand Down
24 changes: 11 additions & 13 deletions src/main/java/edu/stanford/protege/webprotege/sharing/Roles.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public static Optional<SharingPermission> toSharingPermission(Collection<RoleId
else if(roles.contains(CAN_EDIT.getRoleId())) {
return Optional.of(SharingPermission.EDIT);
}
else if(roles.contains(CAN_COMMENT.getRoleId())) {
else if(roles.contains(ICD_CAN_EDIT.getRoleId())) {
return Optional.of(SharingPermission.ICD_EDIT);
}else if(roles.contains(CAN_COMMENT.getRoleId())) {
return Optional.of(SharingPermission.COMMENT);
}
else if(roles.contains(CAN_VIEW.getRoleId())) {
Expand All @@ -34,17 +36,13 @@ else if(roles.contains(CAN_VIEW.getRoleId())) {
}

public static ImmutableSet<RoleId> fromSharingPermission(SharingPermission sharingPermission) {
switch (sharingPermission) {
case MANAGE:
return ImmutableSet.of(CAN_MANAGE.getRoleId());
case EDIT:
return ImmutableSet.of(CAN_EDIT.getRoleId());
case COMMENT:
return ImmutableSet.of(CAN_COMMENT.getRoleId());
case VIEW:
return ImmutableSet.of(CAN_VIEW.getRoleId());
default:
return ImmutableSet.of();
}
return switch (sharingPermission) {
case MANAGE -> ImmutableSet.of(CAN_MANAGE.getRoleId());
case EDIT -> ImmutableSet.of(CAN_EDIT.getRoleId());
case ICD_EDIT -> ImmutableSet.of(ICD_CAN_EDIT.getRoleId());
case COMMENT -> ImmutableSet.of(CAN_COMMENT.getRoleId());
case VIEW -> ImmutableSet.of(CAN_VIEW.getRoleId());
default -> ImmutableSet.of();
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public enum SharingPermission implements Serializable {
*/
EDIT,

ICD_EDIT,

/**
* A user can manage a project
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public UserDetailsManagerImpl(UserRecordRepository userRecordRepository, Command
@Override
public List<UserId> getUserIdsContainingIgnoreCase(String userName, int limit) {
try {
return getUsersExecutor.execute(new UsersQueryRequest(userName), new ExecutionContext()).get().completions();
return getUsersExecutor.execute(new UsersQueryRequest(userName, false), new ExecutionContext()).get().completions();
} catch (Exception e) {
logger.error("Error calling get users",e);
return new ArrayList<>();
Expand Down Expand Up @@ -68,7 +68,7 @@ public Optional<String> getEmail(UserId userId) {
return Optional.empty();
}
Optional<UserRecord> record = repository.findOne(userId);
if (!record.isPresent()) {
if (record.isEmpty()) {
return Optional.empty();
}
String emailAddress = record.get().getEmailAddress();
Expand All @@ -88,7 +88,7 @@ public void setEmail(UserId userId, String email) {
return;
}
Optional<UserRecord> record = repository.findOne(userId);
if (!record.isPresent()) {
if (record.isEmpty()) {
logger.info("Specified user ({}) does not exist.", userId.id());
return;
}
Expand All @@ -112,7 +112,7 @@ public void setEmail(UserId userId, String email) {
@Override
public Optional<UserId> getUserByUserIdOrEmail(String userNameOrEmail) {
try{
List<UserId> response = getUsersExecutor.execute(new UsersQueryRequest(userNameOrEmail), new ExecutionContext()).get(3, TimeUnit.SECONDS).completions();
List<UserId> response = getUsersExecutor.execute(new UsersQueryRequest(userNameOrEmail,true), new ExecutionContext()).get(3, TimeUnit.SECONDS).completions();
if(response == null || response.isEmpty()) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package edu.stanford.protege.webprotege.user;

import com.fasterxml.jackson.annotation.*;
import edu.stanford.protege.webprotege.common.Request;

public record UsersQueryRequest(String userName) implements Request<UsersQueryResponse> {
@JsonTypeName(UsersQueryRequest.CHANNEL)
public record UsersQueryRequest(@JsonProperty("completionText") String userName, @JsonProperty("exactMatch") boolean exactMatch) implements Request<UsersQueryResponse> {

public final static String CHANNEL = "webprotege.usersquery.QueryUsers";

Expand Down
Loading