Source:
public void deleteRelatedContent(final Contentlet contentlet, final Relationship relationship, final boolean hasParent, final User user, final boolean respectFrontendRoles, final List<Contentlet> contentletsToBeRelated) throws DotDataException, DotSecurityException, DotContentletStateException { if (!permissionAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_EDIT, user, respectFrontendRoles)) { throw new DotSecurityException("User: " + (user != null ? user.getUserId() : "Unknown") + " cannot edit Contentlet"); } List<Relationship> rels = FactoryLocator.getRelationshipFactory() .byContentType(contentlet.getContentType()); if (!rels.contains(relationship)) { throw new DotContentletStateException( "Error deleting existing relationships in contentlet: " + (contentlet != null ? contentlet.getInode() : "Unknown")); } List<Contentlet> cons = relationshipAPI .dbRelatedContent(relationship, contentlet, hasParent); cons = permissionAPI .filterCollection(cons, PermissionAPI.PERMISSION_READ, respectFrontendRoles, user); FactoryLocator.getRelationshipFactory().deleteByContent(contentlet, relationship, cons); final List<String> identifiersToBeRelated = contentletsToBeRelated.stream().map( Contentlet::getIdentifier).collect(Collectors.toList()); if (cons != null && !hasParent) { for (final Contentlet relatedContentlet : cons) { if (!identifiersToBeRelated.contains(relatedContentlet.getIdentifier())) { relatedContentlet.setIndexPolicy(contentlet.getIndexPolicyDependencies()); relatedContentlet .setIndexPolicyDependencies(contentlet.getIndexPolicyDependencies()); refreshNoDeps(relatedContentlet); } } } if (!contentlet.getBoolProperty(CHECKIN_IN_PROGRESS)) { refreshNoDeps(contentlet); } }

Target:
public void deleteRelatedContent(final Contentlet contentlet, final Relationship relationship, final boolean hasParent, final User user, final boolean respectFrontendRoles, final List<Contentlet> contentletsToBeRelated) throws DotDataException, DotSecurityException, DotContentletStateException { if (!permissionAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_EDIT, user, respectFrontendRoles)) { throw new DotSecurityException("User: " + (user != null ? user.getUserId() : "Unknown") + " cannot edit Contentlet with identifier " + contentlet.getIdentifier()); } List<Relationship> rels = FactoryLocator.getRelationshipFactory() .byContentType(contentlet.getContentType()); if (!rels.contains(relationship)) { throw new DotContentletStateException( "Error deleting existing relationships in contentlet: " + (contentlet != null ? contentlet.getInode() : "Unknown")); } List<Contentlet> cons = relationshipAPI .dbRelatedContent(relationship, contentlet, hasParent); cons = permissionAPI .filterCollection(cons, PermissionAPI.PERMISSION_READ, respectFrontendRoles, user); FactoryLocator.getRelationshipFactory().deleteByContent(contentlet, relationship, cons); final List<String> identifiersToBeRelated = contentletsToBeRelated.stream().map( Contentlet::getIdentifier).collect(Collectors.toList()); if (cons != null && !hasParent) { for (final Contentlet relatedContentlet : cons) { if (!identifiersToBeRelated.contains(relatedContentlet.getIdentifier())) { relatedContentlet.setIndexPolicy(contentlet.getIndexPolicyDependencies()); relatedContentlet .setIndexPolicyDependencies(contentlet.getIndexPolicyDependencies()); refreshNoDeps(relatedContentlet); } } } if (!contentlet.getBoolProperty(CHECKIN_IN_PROGRESS)) { refreshNoDeps(contentlet); } }