Skip to content

Commit 7716efd

Browse files
authored
Revert "Including second level related content (dotCMS#31054)" (dotCMS#31412)
Some customers reported that after change dotCMS#31036, their Push actions included too many items. To address this, we decided to revert the change and look for a better solution to the original issue. We created a new card to work in the new fix dotCMS#31400 ### Proposed Changes * reverting this PR dotCMS@af3b967
1 parent fa25e53 commit 7716efd

File tree

2 files changed

+11
-198
lines changed

2 files changed

+11
-198
lines changed

dotCMS/src/main/java/com/dotcms/publisher/util/dependencies/PushPublishigDependencyProcesor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,10 @@ private void processContentDependency(final Contentlet contentlet)
479479
if(publisherFilter.isRelationships() && publisherFilter.isDependencies()) {
480480
for (Entry<Relationship, List<Contentlet>> relationshipListEntry : contentRelationships
481481
.entrySet()) {
482+
contentsToProcess.addAll(relationshipListEntry.getValue());
482483

483-
tryToAddAllAndProcessDependencies(PusheableAsset.CONTENTLET,
484-
relationshipListEntry.getValue(), ManifestReason.INCLUDE_DEPENDENCY_FROM.getMessage(relationshipListEntry.getKey()));
484+
tryToAddAll(PusheableAsset.CONTENTLET, relationshipListEntry.getValue(),
485+
ManifestReason.INCLUDE_DEPENDENCY_FROM.getMessage(relationshipListEntry.getKey()));
485486
}
486487
}
487488

dotcms-integration/src/test/java/com/dotcms/publishing/PublisherAPIImplTest.java

Lines changed: 8 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.dotcms.publishing;
22

33
import com.dotcms.LicenseTestUtil;
4-
import com.dotcms.api.web.HttpServletRequestThreadLocal;
5-
import com.dotcms.api.web.HttpServletResponseThreadLocal;
64
import com.dotcms.contenttype.model.field.Field;
75
import com.dotcms.contenttype.model.field.TextField;
86
import com.dotcms.contenttype.model.type.ContentType;
@@ -34,7 +32,6 @@
3432
import com.dotcms.experiments.model.Experiment;
3533
import com.dotcms.experiments.model.ExperimentVariant;
3634
import com.dotcms.languagevariable.business.LanguageVariableAPI;
37-
import com.dotcms.mock.request.MockAttributeRequest;
3835
import com.dotcms.publisher.assets.bean.PushedAsset;
3936
import com.dotcms.publisher.bundle.bean.Bundle;
4037
import com.dotcms.publisher.bundle.business.BundleFactoryImpl;
@@ -52,8 +49,6 @@
5249
import com.dotcms.publishing.manifest.ManifestItem;
5350
import com.dotcms.publishing.manifest.ManifestItem.ManifestInfoBuilder;
5451
import com.dotcms.publishing.manifest.ManifestReason;
55-
import com.dotcms.rendering.velocity.viewtools.content.ContentTool;
56-
import com.dotcms.rendering.velocity.viewtools.content.util.ContentUtils;
5752
import com.dotcms.test.util.FileTestUtil;
5853
import com.dotcms.util.IntegrationTestInitService;
5954
import com.dotcms.variant.model.Variant;
@@ -84,8 +79,6 @@
8479
import com.dotmarketing.portlets.workflows.model.WorkflowStep;
8580
import com.dotmarketing.util.Config;
8681
import com.dotmarketing.util.Logger;
87-
import com.dotmarketing.util.PageMode;
88-
import com.dotmarketing.util.WebKeys;
8982
import com.liferay.portal.model.User;
9083
import com.liferay.util.FileUtil;
9184
import com.liferay.util.StringPool;
@@ -104,9 +97,14 @@
10497
import org.junit.Test;
10598
import org.junit.runner.RunWith;
10699

107-
import javax.servlet.http.HttpServletRequest;
108-
import javax.servlet.http.HttpServletResponse;
109-
import java.io.*;
100+
import java.io.BufferedInputStream;
101+
import java.io.BufferedReader;
102+
import java.io.File;
103+
import java.io.FileInputStream;
104+
import java.io.FileReader;
105+
import java.io.IOException;
106+
import java.io.InputStream;
107+
import java.io.OutputStream;
110108
import java.net.HttpURLConnection;
111109
import java.net.InetSocketAddress;
112110
import java.nio.file.Files;
@@ -128,7 +126,6 @@
128126
import static com.dotcms.variant.VariantAPI.DEFAULT_VARIANT;
129127
import static org.junit.Assert.assertEquals;
130128
import static org.junit.Assert.assertTrue;
131-
import static org.mockito.Mockito.mock;
132129

133130

134131
@RunWith(DataProviderRunner.class)
@@ -1455,189 +1452,4 @@ public void testFilterDescriptors() throws IOException {
14551452
}
14561453

14571454
}
1458-
1459-
/**
1460-
* Method to test: {@link PublisherAPIImpl#publish(PublisherConfig)}
1461-
* When:
1462-
* - Create a ContentType called grandChild with just one field: title.
1463-
* - Create a ContentType called child with 2 field: title and a relationship field pointing to grandChild.
1464-
* - Create a ContentType called parent with 2 field: title and a relationship field pointing to child.
1465-
* - Create a grandChild Contentlet with title equals to 'C'
1466-
* - Create a child Contentlet with title equals to 'B' and related with C
1467-
* - Create a parent Contentlet with title equals to 'A' and related with B
1468-
* - Push A
1469-
*
1470-
* Should: send the 3 ContentTypes, the 3 Contentlets and the 2 Relationship
1471-
*
1472-
* @throws DotDataException
1473-
* @throws DotSecurityException
1474-
* @throws DotPublishingException
1475-
* @throws IOException
1476-
*/
1477-
@Test
1478-
public void pushSecondLevelRelatedContent() throws DotDataException, DotSecurityException, DotPublishingException, IOException {
1479-
final Class<? extends Publisher> publisher = GenerateBundlePublisher.class;
1480-
final Host host = new SiteDataGen().nextPersisted();
1481-
1482-
final Field grandChildTitle = new FieldDataGen().name("title").next();
1483-
1484-
final ContentType contentTypeGrandChild = new ContentTypeDataGen()
1485-
.host(host)
1486-
.field(grandChildTitle)
1487-
.nextPersisted();
1488-
1489-
1490-
final Field childTitle = new FieldDataGen().name("title").next();
1491-
1492-
ContentType contentTypeChild = new ContentTypeDataGen()
1493-
.host(host)
1494-
.field(childTitle)
1495-
.nextPersisted();
1496-
1497-
Relationship relationship1 = new FieldRelationshipDataGen()
1498-
.child(contentTypeGrandChild)
1499-
.parent(contentTypeChild)
1500-
.nextPersisted();
1501-
1502-
contentTypeChild = APILocator.getContentTypeAPI(APILocator.systemUser()).find(contentTypeChild.variable());
1503-
1504-
final Field parentTitle = new FieldDataGen().name("title").next();
1505-
1506-
ContentType contentTypeParent = new ContentTypeDataGen()
1507-
.host(host)
1508-
.field(parentTitle)
1509-
.nextPersisted();
1510-
1511-
final Relationship relationship2 = new FieldRelationshipDataGen()
1512-
.child(contentTypeChild)
1513-
.parent(contentTypeParent)
1514-
.nextPersisted();
1515-
1516-
contentTypeParent = APILocator.getContentTypeAPI(APILocator.systemUser()).find(contentTypeParent.variable());
1517-
1518-
final Contentlet grandChildContent = new ContentletDataGen(contentTypeGrandChild).setProperty("title", "C").nextPersisted();
1519-
final Contentlet childContent = new ContentletDataGen(contentTypeChild)
1520-
.setProperty(relationship1.getChildRelationName(), Arrays.asList(grandChildContent))
1521-
.setProperty("title", "B")
1522-
.nextPersisted();
1523-
final Contentlet parentContent = new ContentletDataGen(contentTypeParent)
1524-
.setProperty(relationship2.getChildRelationName(), Arrays.asList(childContent))
1525-
.setProperty("title", "A")
1526-
.nextPersisted();
1527-
1528-
final FilterDescriptor filterDescriptor = new FilterDescriptorDataGen().dependencies(true).relationships(true).nextPersisted();
1529-
final PublisherAPIImpl publisherAPI = new PublisherAPIImpl();
1530-
1531-
final PushPublisherConfig config = new PushPublisherConfig();
1532-
config.setPublishers(list(publisher));
1533-
config.setOperation(PublisherConfig.Operation.PUBLISH);
1534-
config.setLuceneQueries(list());
1535-
config.setId("PublisherAPIImplTest_" + System.currentTimeMillis());
1536-
1537-
new BundleDataGen()
1538-
.pushPublisherConfig(config)
1539-
.addAssets(list(parentContent))
1540-
.filter(filterDescriptor)
1541-
.operation(PublisherConfig.Operation.PUBLISH)
1542-
.setSavePublishQueueElements(true)
1543-
.nextPersisted();
1544-
1545-
final PublishStatus publish = publisherAPI.publish(config);
1546-
1547-
File bundleRoot = publish.getOutputFiles().get(0);
1548-
1549-
final File extractHere = new File(bundleRoot.getParent() + File.separator + config.getName());
1550-
extractTarArchive(bundleRoot, extractHere);
1551-
1552-
List<Object> expected = Arrays.asList(contentTypeParent,
1553-
contentTypeChild, contentTypeGrandChild,
1554-
grandChildContent, childContent,
1555-
parentContent, relationship2, relationship1);
1556-
1557-
for (Object assetToAssert : expected) {
1558-
FileTestUtil.assertBundleFile(extractHere, assetToAssert);
1559-
}
1560-
}
1561-
1562-
/**
1563-
* Method to test: {@link PublisherAPIImpl#publish(PublisherConfig)}
1564-
* When:
1565-
* - Create a ContentType with 2 fields: title and a relationship pointing to itself.
1566-
* - Create a Contentlet with title equals to 'A' pointing to 'B'
1567-
* - Create a Contentlet with title equals to 'B' pointing to 'C'
1568-
* - Create a Contentlet with title equals to 'C' pointing to 'A'
1569-
* - Push A
1570-
*
1571-
* Should: send the ContentType, the 3 Contentlets and the Relationship without any OutOfMemory Exception
1572-
*
1573-
* @throws DotDataException
1574-
* @throws DotSecurityException
1575-
* @throws DotPublishingException
1576-
* @throws IOException
1577-
*/
1578-
@Test
1579-
public void pushCiclyReferenceContentlets() throws DotDataException, DotSecurityException, DotPublishingException, IOException {
1580-
final Class<? extends Publisher> publisher = GenerateBundlePublisher.class;
1581-
final Host host = new SiteDataGen().nextPersisted();
1582-
1583-
final Field titleField = new FieldDataGen().name("title").next();
1584-
1585-
ContentType contentType = new ContentTypeDataGen()
1586-
.host(host)
1587-
.field(titleField)
1588-
.nextPersisted();
1589-
1590-
Relationship relationship = new FieldRelationshipDataGen()
1591-
.child(contentType)
1592-
.parent(contentType)
1593-
.nextPersisted();
1594-
1595-
contentType = APILocator.getContentTypeAPI(APILocator.systemUser()).find(contentType.variable());
1596-
1597-
final Contentlet contentB = new ContentletDataGen(contentType).setProperty("title", "B").nextPersisted();
1598-
final Contentlet contentC = new ContentletDataGen(contentType).setProperty("title", "B").nextPersisted();
1599-
final Contentlet contentA = new ContentletDataGen(contentType)
1600-
.setProperty(relationship.getChildRelationName(), Arrays.asList(contentB))
1601-
.setProperty("title", "A")
1602-
.nextPersisted();
1603-
1604-
final Contentlet checkoutB = ContentletDataGen.checkout(contentB);
1605-
checkoutB.setProperty(relationship.getChildRelationName(), Arrays.asList(contentC));
1606-
ContentletDataGen.checkin(checkoutB);
1607-
1608-
final Contentlet checkoutC = ContentletDataGen.checkout(contentC);
1609-
checkoutC.setProperty(relationship.getChildRelationName(), Arrays.asList(contentA));
1610-
ContentletDataGen.checkin(checkoutC);
1611-
1612-
final FilterDescriptor filterDescriptor = new FilterDescriptorDataGen().dependencies(true).relationships(true).nextPersisted();
1613-
final PublisherAPIImpl publisherAPI = new PublisherAPIImpl();
1614-
1615-
final PushPublisherConfig config = new PushPublisherConfig();
1616-
config.setPublishers(list(publisher));
1617-
config.setOperation(PublisherConfig.Operation.PUBLISH);
1618-
config.setLuceneQueries(list());
1619-
config.setId("PublisherAPIImplTest_" + System.currentTimeMillis());
1620-
1621-
new BundleDataGen()
1622-
.pushPublisherConfig(config)
1623-
.addAssets(list(contentA))
1624-
.filter(filterDescriptor)
1625-
.operation(PublisherConfig.Operation.PUBLISH)
1626-
.setSavePublishQueueElements(true)
1627-
.nextPersisted();
1628-
1629-
final PublishStatus publish = publisherAPI.publish(config);
1630-
1631-
File bundleRoot = publish.getOutputFiles().get(0);
1632-
1633-
final File extractHere = new File(bundleRoot.getParent() + File.separator + config.getName());
1634-
extractTarArchive(bundleRoot, extractHere);
1635-
1636-
List<Object> expected = Arrays.asList(contentType,
1637-
contentA, contentB, contentC, relationship);
1638-
1639-
for (Object assetToAssert : expected) {
1640-
FileTestUtil.assertBundleFile(extractHere, assetToAssert);
1641-
}
1642-
}
16431455
}

0 commit comments

Comments
 (0)