diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortletUtils.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortletUtils.java index 3bda3e0655..77c03010bc 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortletUtils.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/common/PortletUtils.java @@ -54,6 +54,8 @@ import javax.portlet.ResourceResponse; import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.stream.Collectors; @@ -76,6 +78,16 @@ public class PortletUtils { private static final String TEMPLATE_FILE = "/welcomePageGuideline.html"; private static final ObjectMapper objectMapper = new ObjectMapper(); private static ChangeLogsPortletUtils changeLogsPortletUtils = null; + private static String EXTERNALID_BLOCKLIST_CLONING_RELEASE; + private static final String PROPERTIES_FILE_PATH = "/sw360.properties"; + + static { + CommonUtils.loadProperties(PortletUtils.class, PROPERTIES_FILE_PATH); + Properties props = CommonUtils.loadProperties(PortletUtils.class, PROPERTIES_FILE_PATH); + + EXTERNALID_BLOCKLIST_CLONING_RELEASE = props.getProperty("release.externalId.to.be.removed.while.cloning", ""); + } + private PortletUtils() { // Utility class with only static functions @@ -289,6 +301,14 @@ public static Set updateAttachmentsFromRequest(PortletRequest reques public static Release cloneRelease(String emailFromRequest, Release release) { Release newRelease = release.deepCopy(); + Map extIdHmap = new ConcurrentHashMap(); + extIdHmap = release.getExternalIds(); + for (Entry names : extIdHmap.entrySet()) { + if (names.getKey() != null && names.getKey().equals(EXTERNALID_BLOCKLIST_CLONING_RELEASE)) { + extIdHmap.remove(names.getKey()); + } + } + newRelease.setExternalIds(extIdHmap); //new DB object newRelease.unsetId(); diff --git a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/components/ComponentPortlet.java b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/components/ComponentPortlet.java index 4d044eb8c0..97238c01a8 100644 --- a/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/components/ComponentPortlet.java +++ b/frontend/sw360-portlet/src/main/java/org/eclipse/sw360/portal/portlets/components/ComponentPortlet.java @@ -1077,6 +1077,7 @@ private void prepareReleaseDuplicate(RenderRequest request, RenderResponse respo request.setAttribute(RELEASE_LIST, Collections.emptyList()); request.setAttribute(TOTAL_INACCESSIBLE_ROWS, 0); setUsingDocs(request, null, user, client); + release.unsetExternalIds(); request.setAttribute(RELEASE, release); request.setAttribute(PortalConstants.ATTACHMENTS, Collections.emptySet()); diff --git a/frontend/sw360-portlet/src/main/resources/sw360.properties b/frontend/sw360-portlet/src/main/resources/sw360.properties index e3cb00e685..76d7f914d3 100644 --- a/frontend/sw360-portlet/src/main/resources/sw360.properties +++ b/frontend/sw360-portlet/src/main/resources/sw360.properties @@ -91,6 +91,7 @@ #key.auth.givenname=GIVENNAME #key.auth.surname=SURNAME #key.auth.department=DEPARTMENT +release.externalId.to.be.removed.while.cloning= ## OrganizationHelper #match.prefix=false