Skip to content

Commit

Permalink
fix/svmcomponentids - do not copy svm component ids
Browse files Browse the repository at this point in the history
fix(rest): added for SVM COMPONENT ID not be cloned while doing dublicate

Signed-off-by: Nikesh kumar <kumar.nikesh@simens.com>

fix(UI): code modification for do not copy component ids

Signed-off-by: Nikesh kumar <kumar.nikesh@simens.com>
  • Loading branch information
Nikesh kumar committed Sep 5, 2022
1 parent 85a09da commit c52d330
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -289,6 +301,14 @@ public static Set<Attachment> updateAttachmentsFromRequest(PortletRequest reques
public static Release cloneRelease(String emailFromRequest, Release release) {

Release newRelease = release.deepCopy();
Map<String, String> extIdHmap = new ConcurrentHashMap<String, String>();
extIdHmap = release.getExternalIds();
for (Entry<String, String> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
1 change: 1 addition & 0 deletions frontend/sw360-portlet/src/main/resources/sw360.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c52d330

Please sign in to comment.