Skip to content

Commit

Permalink
#25044 #24705 include in 22.03.7
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Jun 14, 2023
1 parent 0aa2714 commit d7b089e
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 16 deletions.
4 changes: 3 additions & 1 deletion HOTFIX_TRACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,6 @@ This maintenance release includes the following code fixes:
117. https://github.com/dotCMS/core/issues/24059 : We are not respecting the widget language when you have a multilingual page have a working version in non-default language #24059
118. https://github.com/dotCMS/core/issues/24133 : User is unable to lock content because of validation limit on locked_by column of contentlet_version_info #24133
119. https://github.com/dotCMS/core/issues/24286 : Creating a content in a third language in a row throws an error #24286
120. https://github.com/dotCMS/core/issues/25097 : Update Normalization Filter #25097
120. https://github.com/dotCMS/core/issues/25097 : Update Normalization Filter #25097
121. https://github.com/dotCMS/core/issues/25044 : PP content set as working state instead of live state when there is archived version in other language #25044
122. https://github.com/dotCMS/core/issues/24705 : PP a folder with Archived Content Fails #24705
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.dotcms.contenttype.model.type.ContentTypeBuilder;
import com.dotcms.contenttype.model.type.SimpleContentType;
import com.dotcms.datagen.ContentletDataGen;
import com.dotcms.datagen.TestDataUtils;
import com.dotcms.enterprise.publishing.remote.bundler.ContentBundler;
import com.dotcms.publisher.bundle.bean.Bundle;
import com.dotcms.publisher.endpoint.bean.PublishingEndPoint;
Expand All @@ -34,6 +35,7 @@
import com.dotmarketing.portlets.folders.business.FolderAPI;
import com.dotmarketing.portlets.folders.model.Folder;
import com.dotmarketing.portlets.htmlpageasset.model.HTMLPageAsset;
import com.dotmarketing.portlets.languagesmanager.model.Language;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.UtilMethods;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -121,7 +123,18 @@ public void test_Create_folderpage_Push_page_Remove_folderpush_Create_page_Push_
}
}
}

/**
* Test the push of a content with a unique field
* Method to test: {@link com.dotcms.publisher.receiver.BundlePublisher#process(PublishStatus)}
* When:
* - Create a ContentType with a unique field
* - Create a {@link Contentlet} with a value for the unique field and add it to a bundle
* - Delete the {@link Contentlet} from the previous step
* - Create a new {@link Contentlet} with a different value for the unique field
* - Push publish the bundle
* Should: The {@link Contentlet} from the bundle with the unique field should replace
* the {@link Contentlet} version with a different value for the unique field
*/
@Test
public void testPushContentWithUniqueField() throws Exception {

Expand All @@ -136,7 +149,7 @@ public void testPushContentWithUniqueField() throws Exception {
try {

// Create test content type
testContentType = createContentType("Test Content Type", systemUser);
testContentType = createContentType("Test Content Type", systemUser, true);

// Create test environment and endpoint
final User adminUser = APILocator.getUserAPI().loadByUserByEmail("admin@dotcms.com",
Expand Down Expand Up @@ -175,20 +188,97 @@ public void testPushContentWithUniqueField() throws Exception {

} finally {

if (UtilMethods.isSet(resultContentlet)) {
APILocator.getContentletAPI().destroy(resultContentlet, systemUser, false );
}
deleteTestPPData(systemUser, testContentType, ppBean, resultContentlet);

if (UtilMethods.isSet(ppBean)) {
PublisherTestUtil.cleanBundleEndpointEnv(null, ppBean.endPoint, ppBean.environment);
}
}
}

if (UtilMethods.isSet(testContentType) && UtilMethods.isSet(testContentType.id())) {
APILocator.getContentTypeAPI(systemUser).delete(testContentType);
}
/**
* Test the push of a multi-language content, with an archived version
* Method to test: {@link com.dotcms.publisher.receiver.BundlePublisher#process(PublishStatus)}
* When:
* - Create a ContentType with title and description fields
* - Create a {@link Contentlet} with the default language and publish it
* - Create a {@link Contentlet} with a different language and archive it
* - Push publish the content
* Should: The {@link Contentlet} version with the default language should be in live state
* and the {@link Contentlet} version with a different language should be archived
*/
@Test
public void testPushArchivedAndMultiLanguageContent() throws Exception {

}
final User systemUser = APILocator.getUserAPI().getSystemUser();
ContentType testContentType = null;
PPBean ppBean = null;
Contentlet resultContentlet = null;

final Language defaultLanguage = APILocator.getLanguageAPI().getDefaultLanguage();
final Language spanishLanguage = TestDataUtils.getSpanishLanguage();

final String defaultLangTitle = "Default Title";
final String defaultLangDescription = "Default Description";
final String spanishLangTitle = "Spanish Title";
final String spanishLangDescription = "Spanish Description";

try {

// Create test content type
testContentType = createContentType("Test Content Type", systemUser, false);

// Create test environment and endpoint
final User adminUser = APILocator.getUserAPI().loadByUserByEmail("admin@dotcms.com",
systemUser, false);
ppBean = createPushPublishEnv(adminUser);
assertPPBean(ppBean);

// Generate bundle
final Contentlet contentlet = new ContentletDataGen(testContentType.id())
.languageId(defaultLanguage.getId())
.setProperty(TEST_TITLE, defaultLangTitle)
.setProperty(TEST_DESCRIPTION, defaultLangDescription).nextPersisted();
ContentletDataGen.publish(contentlet);

final Contentlet spanishCotentlet = ContentletDataGen.checkout(contentlet);
spanishCotentlet.setLanguageId(spanishLanguage.getId());
spanishCotentlet.setProperty(TEST_TITLE, spanishLangTitle);
spanishCotentlet.setProperty(TEST_DESCRIPTION, spanishLangDescription);
ContentletDataGen.checkin(spanishCotentlet);
ContentletDataGen.archive(spanishCotentlet);

final Map<String, Object> bundleData = generateContentBundle(
"archived-multi-language-content-test-1", contentlet, adminUser, ppBean);
assertNotNull(bundleData);
assertNotNull(bundleData.get(PublisherTestUtil.FILE));

final String contentIdentifier = contentlet.getIdentifier();
APILocator.getContentletAPI().destroy(contentlet, adminUser, false );

// Publish bundle
final PublisherConfig publisherConfig = publishContentBundle(
(File) bundleData.get(PublisherTestUtil.FILE), ppBean.endPoint);
assertNotNull(publisherConfig);
assertEquals(((File) bundleData.get(PublisherTestUtil.FILE)).getName(),
publisherConfig.getId());

// Check result content
resultContentlet = APILocator.getContentletAPI()
.findContentletByIdentifier(contentIdentifier,
false, spanishLanguage.getId(), adminUser, false);
assertNotNull(resultContentlet);
assertEquals(spanishLangTitle, resultContentlet.getStringProperty(TEST_TITLE));
assertTrue(resultContentlet.isArchived());

resultContentlet = APILocator.getContentletAPI()
.findContentletByIdentifier(contentIdentifier,
true, defaultLanguage.getId(), adminUser, false);
assertNotNull(resultContentlet);
assertEquals(defaultLangTitle, resultContentlet.getStringProperty(TEST_TITLE));

} finally {

deleteTestPPData(systemUser, testContentType, ppBean, resultContentlet);

}
}

private FolderPage createNewPage (final FolderPage folderPage, final User user) throws Exception {
Expand Down Expand Up @@ -289,7 +379,8 @@ private PushResult removePushFolder(final String bundleName, final FolderPage fo
new PushResult(bundle, PublisherTestUtil.remoteRemove (assets, bundle, user), assetRealPath + "/bundles/" + bundle.getId());
}

private ContentType createContentType(final String contentTypeName, final User user)
private ContentType createContentType(final String contentTypeName,
final User user, final boolean uniqueTitle)
throws DotSecurityException, DotDataException {

final long time = System.currentTimeMillis();
Expand All @@ -303,14 +394,14 @@ private ContentType createContentType(final String contentTypeName, final User u

final Field textField = FieldBuilder.builder(TextField.class).name(TEST_TITLE)
.variable(TEST_TITLE).contentTypeId(contentType.id()).required(true)
.listed(true).unique(true).indexed(true).sortOrder(1).readOnly(false)
.listed(true).unique(uniqueTitle).indexed(true).sortOrder(1).readOnly(false)
.fixed(false).searchable(true).dataType(DataTypes.TEXT).build();

APILocator.getContentTypeFieldAPI().save(textField, user);

final Field descField = FieldBuilder.builder(TextField.class).name(TEST_DESCRIPTION)
.variable(TEST_DESCRIPTION).contentTypeId(contentType.id()).required(false)
.listed(false).unique(false).indexed(false).sortOrder(1).readOnly(false)
.listed(false).unique(false).indexed(false).sortOrder(2).readOnly(false)
.fixed(false).searchable(false).dataType(DataTypes.TEXT).build();

APILocator.getContentTypeFieldAPI().save(descField, user);
Expand All @@ -319,6 +410,20 @@ private ContentType createContentType(final String contentTypeName, final User u

}

private void deleteTestPPData(User systemUser, ContentType testContentType, PPBean ppBean, Contentlet resultContentlet) throws DotDataException, DotSecurityException {
if (UtilMethods.isSet(resultContentlet)) {
APILocator.getContentletAPI().destroy(resultContentlet, systemUser, false );
}

if (UtilMethods.isSet(ppBean)) {
PublisherTestUtil.cleanBundleEndpointEnv(null, ppBean.endPoint, ppBean.environment);
}

if (UtilMethods.isSet(testContentType) && UtilMethods.isSet(testContentType.id())) {
APILocator.getContentTypeAPI(systemUser).delete(testContentType);
}
}

private Map<String, Object> generateContentBundle(final String bundleName,
final Contentlet contentlet,
final User user, final PPBean ppBean)
Expand Down

0 comments on commit d7b089e

Please sign in to comment.