From a060b25c0de17f9c141d5695aa0dcc106f05f1e4 Mon Sep 17 00:00:00 2001 From: Leonardo Canessa Date: Wed, 5 Apr 2017 20:31:10 -0400 Subject: [PATCH] SAK-31068 Add Forums Import As Draft setting (#2368) * SAK-31068 Add Forums Import As Draft setting This feature allows the forums tool to have it's own importAsDraft functionality. * SAK-31068 Fixup Logic change error * SAK-31068 Use import.importAsDraft as default also... changed all instances of retrieving import.importAsDraft from getString to getBoolean because getting a string is of a boolean is dumb and needless. --- .../announcement/impl/BaseAnnouncementService.java | 2 +- .../assignment/impl/BaseAssignmentService.java | 4 ++-- .../config/bundle/default.sakai.properties | 11 +++++++++++ .../org/sakaiproject/message/util/BaseMessage.java | 2 +- .../app/messageforums/DiscussionForumServiceImpl.java | 10 +++++++--- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/announcement/announcement-impl/impl/src/java/org/sakaiproject/announcement/impl/BaseAnnouncementService.java b/announcement/announcement-impl/impl/src/java/org/sakaiproject/announcement/impl/BaseAnnouncementService.java index db0f99093e3b..bd2d22ef0e9e 100644 --- a/announcement/announcement-impl/impl/src/java/org/sakaiproject/announcement/impl/BaseAnnouncementService.java +++ b/announcement/announcement-impl/impl/src/java/org/sakaiproject/announcement/impl/BaseAnnouncementService.java @@ -1258,7 +1258,7 @@ public Map transferCopyEntitiesRefMigrator(String fromContext, S nMessageHeader.setDate(oMessageHeader.getDate()); nMessageHeader.setMessage_order(oMessageHeader.getMessage_order()); // when importing, refer to property to determine draft status - if ("false".equalsIgnoreCase(m_serverConfigurationService.getString("import.importAsDraft"))) + if (!m_serverConfigurationService.getBoolean("import.importAsDraft", true)) { nMessageHeader.setDraft(oMessageHeader.getDraft()); } diff --git a/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java b/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java index 014a5293c9a1..814ab7dd615c 100644 --- a/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java +++ b/assignment/assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/BaseAssignmentService.java @@ -6601,7 +6601,7 @@ else if (oldUrl.startsWith("/content/group/" + fromSiteId + "/")) } // for // when importing, refer to property to determine draft status - if ("false".equalsIgnoreCase(m_serverConfigurationService.getString("import.importAsDraft"))) + if (!m_serverConfigurationService.getBoolean("import.importAsDraft", true)) { String draftAttribute = el2clone.getAttribute("draft"); if (draftAttribute.equalsIgnoreCase("true") || draftAttribute.equalsIgnoreCase("false")) @@ -6767,7 +6767,7 @@ public Map transferCopyEntitiesRefMigrator(String fromContext, S nAssignment.setContext(toContext); // when importing, refer to property to determine draft status - if ("false".equalsIgnoreCase(m_serverConfigurationService.getString("import.importAsDraft"))) + if (!m_serverConfigurationService.getBoolean("import.importAsDraft", true)) { nAssignment.setDraft(oAssignment.getDraft()); } diff --git a/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties b/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties index 7871043920fb..9922124ad5fe 100644 --- a/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties +++ b/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties @@ -1772,6 +1772,12 @@ # DEFAULT: use the categories defined in the tool xml file # tool.categories.{toolid}=category1,category2,category3 +# Controls whether when importing / duplicating a site to have them be as draft +# Applies to announcements, assignments, and messages +# msgcntr has own property of msgcntr.forums.import.importAsDraft +# DEFAULT: true +# import.importAsDraft=false + # GRADEBOOK 1 # Controls the display of the number of decimal points for the class average. # In Gradebook Items -> {click on an item}. @@ -3850,6 +3856,11 @@ # DEFAULT: false # msgcntr.forums.revealIDsToRoles.revisable=false +# SAK-31068 Configure forums Import / Duplication behavior +# By default, will set imported objects in Draft mode +# DEFAULT: true +# msgcntr.forums.import.importAsDraft=false + ## SAK-19178 # Should we load the initial jobs on startup. # - "init" will schedule the jobs *only* on the first startup of Sakai. diff --git a/message/message-util/util/src/java/org/sakaiproject/message/util/BaseMessage.java b/message/message-util/util/src/java/org/sakaiproject/message/util/BaseMessage.java index 8d4f97f195db..85b65f5dd080 100644 --- a/message/message-util/util/src/java/org/sakaiproject/message/util/BaseMessage.java +++ b/message/message-util/util/src/java/org/sakaiproject/message/util/BaseMessage.java @@ -1979,7 +1979,7 @@ else if (element2.getTagName().equals(SYNOPTIC_TOOL)) } // TODO: reall want a draft? -ggolden // set draft status based upon property setting - if ("false".equalsIgnoreCase(m_serverConfigurationService.getString("import.importAsDraft"))) + if (!m_serverConfigurationService.getBoolean("import.importAsDraft", true)) { String draftAttribute = element4.getAttribute("draft"); if (draftAttribute.equalsIgnoreCase("true") || draftAttribute.equalsIgnoreCase("false")) diff --git a/msgcntr/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/DiscussionForumServiceImpl.java b/msgcntr/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/DiscussionForumServiceImpl.java index 25dd0192444e..45928b5482a9 100644 --- a/msgcntr/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/DiscussionForumServiceImpl.java +++ b/msgcntr/messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/DiscussionForumServiceImpl.java @@ -517,7 +517,7 @@ public Map transferCopyEntitiesRefMigrator(String fromContext, S Area area = areaManager.getDiscussionArea(toContext, false); newForum.setArea(area); - if ("false".equalsIgnoreCase(ServerConfigurationService.getString("import.importAsDraft"))) + if (!getImportAsDraft()) { forumManager.saveDiscussionForum(newForum, newForum.getDraft().booleanValue()); } @@ -923,7 +923,7 @@ else if (propertiesElement.getTagName().equals(PERMISSIONS)) { { Area area = areaManager.getDiscussionArea(siteId); dfForum.setArea(area); - if ("false".equalsIgnoreCase(ServerConfigurationService.getString("import.importAsDraft"))) + if (!getImportAsDraft()) { forumManager.saveDiscussionForum(dfForum, dfForum.getDraft().booleanValue()); } @@ -944,7 +944,7 @@ else if (propertiesElement.getTagName().equals(PERMISSIONS)) { { Area area = areaManager.getDiscussionArea(siteId); dfForum.setArea(area); - if ("false".equalsIgnoreCase(ServerConfigurationService.getString("import.importAsDraft"))) + if (!getImportAsDraft()) { forumManager.saveDiscussionForum(dfForum, dfForum.getDraft().booleanValue()); } @@ -1360,5 +1360,9 @@ private String replaceAllRefs(String msgBody, Set> entrySe return msgBody; } + private Boolean getImportAsDraft() { + boolean importAsDraft = ServerConfigurationService.getBoolean("import.importAsDraft", true); + return ServerConfigurationService.getBoolean("msgcntr.forums.import.importAsDraft", importAsDraft); + } }