From 36555b52dfc852fd142f0fce15062b2006882448 Mon Sep 17 00:00:00 2001 From: Steve Springett Date: Wed, 20 Jun 2018 14:46:11 -0500 Subject: [PATCH] Fixed permission synchronization issue that prevented new permissions from being added to the database on upgrades. --- .../persistence/DefaultObjectGenerator.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/owasp/dependencytrack/persistence/DefaultObjectGenerator.java b/src/main/java/org/owasp/dependencytrack/persistence/DefaultObjectGenerator.java index 417490f49d..3f9de64e0e 100644 --- a/src/main/java/org/owasp/dependencytrack/persistence/DefaultObjectGenerator.java +++ b/src/main/java/org/owasp/dependencytrack/persistence/DefaultObjectGenerator.java @@ -57,9 +57,9 @@ public void contextInitialized(ServletContextEvent event) { Event.dispatch(new IndexEvent(IndexEvent.Action.COMMIT, Vulnerability.class)); Event.dispatch(new IndexEvent(IndexEvent.Action.COMMIT, License.class)); - loadDefaultLicenses(); loadDefaultPermissions(); loadDefaultPersonas(); + loadDefaultLicenses(); loadDefaultRepositories(); try { @@ -104,12 +104,11 @@ private void loadDefaultLicenses() { */ private void loadDefaultPermissions() { try (QueryManager qm = new QueryManager()) { - if (qm.getPermissions().size() > 0) { - return; - } - LOGGER.info("Adding default permissions to datastore."); + LOGGER.info("Synchronizing permissions to datastore."); for (Permissions permission : Permissions.values()) { - qm.createPermission(permission.name(), permission.getDescription()); + if (qm.getPermission(permission.name()) == null) { + qm.createPermission(permission.name(), permission.getDescription()); + } } } }