diff --git a/.gitignore b/.gitignore
index 1061d9f839..3c5a35f63a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,8 +7,12 @@ target/
.classpath
.project
.settings/
+**/.factorypath
out/
+# https://www.jenv.be/
+.java-version
+
logs/
velocity.log.*
@@ -16,4 +20,17 @@ velocity.log.*
dependency-reduced-pom.xml
-.protegedata/
\ No newline at end of file
+.protegedata/
+
+# Package Files
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+replay_pid*
diff --git a/pom.xml b/pom.xml
index 52e058036e..1c7dcb525a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -273,8 +273,9 @@
+
maven-dependency-plugin
- 3.1.1
+ 3.1.2
diff --git a/webprotege-server-api/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepository.java b/webprotege-server-api/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepository.java
index 77c7bb65d3..a6855560c6 100644
--- a/webprotege-server-api/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepository.java
+++ b/webprotege-server-api/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepository.java
@@ -16,7 +16,7 @@ public interface TagRepository {
void saveTag(@Nonnull Tag tag);
- void saveTags(@Nonnull Iterable tags);
+ void saveTags(@Nonnull List tags);
void deleteTag(@Nonnull TagId tagId);
diff --git a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/jackson/ObjectMapperProvider.java b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/jackson/ObjectMapperProvider.java
index 766a12f319..971db90171 100644
--- a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/jackson/ObjectMapperProvider.java
+++ b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/jackson/ObjectMapperProvider.java
@@ -13,10 +13,15 @@
import org.semanticweb.owlapi.model.*;
import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl;
+import java.util.concurrent.atomic.AtomicInteger;
+
import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.inject.Provider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Matthew Horridge
* Stanford Center for Biomedical Informatics Research
@@ -27,6 +32,10 @@ public class ObjectMapperProvider implements Provider {
@Nonnull
private final OWLDataFactory dataFactory;
+ private static Logger logger = LoggerFactory.getLogger(ObjectMapperProvider.class);
+
+ private static AtomicInteger mapperInstanceCount = new AtomicInteger();
+
@Inject
public ObjectMapperProvider() {
this.dataFactory = new OWLDataFactoryImpl();
@@ -35,6 +44,9 @@ public ObjectMapperProvider() {
@Override
public ObjectMapper get() {
ObjectMapper mapper = new ObjectMapper();
+ int instanceCount = mapperInstanceCount.incrementAndGet();
+ String msg = String.format("Instantiated another ObjectMappger#%08x, total: %d", mapper.hashCode(), instanceCount);
+ logger.info(msg);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setDefaultPrettyPrinter(new DefaultPrettyPrinter());
mapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
diff --git a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/search/EntitySearchFilterRepositoryImpl.java b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/search/EntitySearchFilterRepositoryImpl.java
index f568fa4056..3648fc7f04 100644
--- a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/search/EntitySearchFilterRepositoryImpl.java
+++ b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/search/EntitySearchFilterRepositoryImpl.java
@@ -94,6 +94,8 @@ public ImmutableList getSearchFilters(@Nonnull ProjectId pro
public void saveSearchFilters(@Nonnull ImmutableList filters) {
try {
writeLock.lock();
+ if (filters.size() < 1)
+ return;
var writes = filters.stream()
.map(this::toMongoDocument)
.map(this::toReplaceOne)
diff --git a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/sharing/ProjectSharingSettingsManagerImpl.java b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/sharing/ProjectSharingSettingsManagerImpl.java
index 5563db78b1..039e2cb571 100644
--- a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/sharing/ProjectSharingSettingsManagerImpl.java
+++ b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/sharing/ProjectSharingSettingsManagerImpl.java
@@ -1,6 +1,25 @@
package edu.stanford.bmir.protege.web.server.sharing;
+import static edu.stanford.bmir.protege.web.server.access.Subject.forAnySignedInUser;
+import static edu.stanford.bmir.protege.web.server.access.Subject.forUser;
+import static java.util.Collections.emptySet;
+import static java.util.stream.Collectors.toMap;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.google.common.collect.ImmutableSet;
+import com.mongodb.DuplicateKeyException;
+
import edu.stanford.bmir.protege.web.server.access.AccessManager;
import edu.stanford.bmir.protege.web.server.access.ProjectResource;
import edu.stanford.bmir.protege.web.server.access.Subject;
@@ -12,16 +31,6 @@
import edu.stanford.bmir.protege.web.shared.sharing.SharingPermission;
import edu.stanford.bmir.protege.web.shared.sharing.SharingSetting;
import edu.stanford.bmir.protege.web.shared.user.UserId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import java.util.*;
-
-import static edu.stanford.bmir.protege.web.server.access.Subject.forAnySignedInUser;
-import static edu.stanford.bmir.protege.web.server.access.Subject.forUser;
-import static java.util.Collections.emptySet;
-import static java.util.stream.Collectors.toMap;
/**
* Matthew Horridge
@@ -66,12 +75,24 @@ public ProjectSharingSettings getProjectSharingSettings(ProjectId projectId) {
@Override
public void setProjectSharingSettings(ProjectSharingSettings settings) {
- ProjectId projectId = settings.getProjectId();
- ProjectResource projectResource = new ProjectResource(projectId);
+ ProjectId projectId = settings.getProjectId();
+ ProjectResource projectResource = new ProjectResource(projectId);
- // Remove existing assignments
- accessManager.getSubjectsWithAccessToResource(projectResource)
- .forEach(subject -> accessManager.setAssignedRoles(subject, projectResource, Collections.emptySet()));
+ // Overwrite existing assignments with blank assignment
+ for (Subject subject : accessManager.getSubjectsWithAccessToResource(projectResource)) {
+ try {
+ logger.info("Subject: {}, resource: {}", subject, projectResource);
+ accessManager.setAssignedRoles(subject, projectResource, Collections.emptySet());
+ } catch (DuplicateKeyException e) {
+ // TODO: fix for intermittent 'E11000 duplicate key error collection:
+ // webprotege.RoleAssignments
+ // index: userName_1_projectId_1
+ // dup key: { userName: null, projectId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ // }'
+ String msg = String.format("Subject: %s, resource: %s", subject, projectResource);
+ logger.warn(msg, e);
+ }
+ }
Map map = settings.getSharingSettings().stream()
.collect(toMap(SharingSetting::getPersonId, s -> s, (s1, s2) -> s1));
@@ -93,7 +114,7 @@ public void setProjectSharingSettings(ProjectSharingSettings settings) {
roles);
}
else {
- logger.info("User in sharing setting not found. An email invitation needs to be sent");
+ logger.warn("User in sharing setting not found. An email invitation needs to be sent");
// TODO
// We need to send the user an email invitation
}
diff --git a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepositoryCachingImpl.java b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepositoryCachingImpl.java
index 1f7ee7e93f..08badfd047 100644
--- a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepositoryCachingImpl.java
+++ b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepositoryCachingImpl.java
@@ -53,7 +53,7 @@ public synchronized void saveTag(@Nonnull Tag tag) {
}
@Override
- public synchronized void saveTags(@Nonnull Iterable tags) {
+ public synchronized void saveTags(@Nonnull List tags) {
delegate.saveTags(tags);
invalidate();
}
diff --git a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepositoryImpl.java b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepositoryImpl.java
index e233494801..6095015f22 100644
--- a/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepositoryImpl.java
+++ b/webprotege-server-core/src/main/java/edu/stanford/bmir/protege/web/server/tag/TagRepositoryImpl.java
@@ -105,8 +105,10 @@ private Document toDocument(@Nonnull Tag tag) {
return objectMapper.convertValue(tag, Document.class);
}
- public void saveTags(@Nonnull Iterable tags) {
+ public void saveTags(@Nonnull List tags) {
writeLock.lock();
+ if (tags.size() < 1)
+ return;
try {
checkNotNull(tags);
Spliterator spliterator = tags.spliterator();
diff --git a/webprotege-server/src/main/java/edu/stanford/bmir/protege/web/server/api/resources/ProjectSettingsResource.java b/webprotege-server/src/main/java/edu/stanford/bmir/protege/web/server/api/resources/ProjectSettingsResource.java
index 3c1705eb37..1d32585708 100644
--- a/webprotege-server/src/main/java/edu/stanford/bmir/protege/web/server/api/resources/ProjectSettingsResource.java
+++ b/webprotege-server/src/main/java/edu/stanford/bmir/protege/web/server/api/resources/ProjectSettingsResource.java
@@ -1,8 +1,24 @@
package edu.stanford.bmir.protege.web.server.api.resources;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+import javax.annotation.Nonnull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
import com.google.auto.factory.AutoFactory;
import com.google.auto.factory.Provided;
import com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import edu.stanford.bmir.protege.web.server.api.ActionExecutor;
import edu.stanford.bmir.protege.web.shared.crud.GetEntityCrudKitSettingsAction;
import edu.stanford.bmir.protege.web.shared.crud.IRIPrefixUpdateStrategy;
@@ -23,21 +39,14 @@
import edu.stanford.bmir.protege.web.shared.tag.TagData;
import edu.stanford.bmir.protege.web.shared.user.UserId;
-import javax.annotation.Nonnull;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.ImmutableList.toImmutableList;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
/**
* Matthew Horridge
* Stanford Center for Biomedical Informatics Research
* 2020-08-24
*/
public class ProjectSettingsResource {
+
+ protected static Logger logger = LoggerFactory.getLogger(ProjectSettingsResource.class);
@Nonnull
private final ProjectId projectId;
@@ -78,6 +87,16 @@ public Response getProjectSettings(@Context UserId userId) {
@POST
@Consumes(APPLICATION_JSON)
public Response setProjectSettings(@Context UserId userId, AllProjectSettings allProjectSettings) {
+ logger.info("Called setProjectSettings for projectId '{}'", this.projectId.getId());
+ try {
+ return _setProjectSettings(userId, allProjectSettings);
+ } catch (Exception e) {
+ logger.error("setProjectSettings failed", e);
+ throw e;
+ }
+ }
+
+ private Response _setProjectSettings(@Context UserId userId, AllProjectSettings allProjectSettings) {
var projectSettings = allProjectSettings.getProjectSettings().withProjectId(projectId);
actionExecutor.execute(new SetProjectSettingsAction(projectSettings), userId);