4

Using Liferay 6.1 CE, is there an easy way to create an 'empty' journalarticle based on a known structureId ?

The following code :

ja = JournalArticleLocalServiceUtil.addArticle(
    themeDisplay.getUserId(),
    themeDisplay.getScopeGroupId(), 
    0, 0, //classNameId, classPK, 
    "test-article", //articleId, 
    false, //autoArticleId, 
    JournalArticleConstants.VERSION_DEFAULT, 
    titleMap,
    null, //descriptionMap,
    content, 
    "general", // type, 
    BamboostConstants.SINGLE_CONTENT_STRUCTURE_ID,
    null, // templateId, 
    StringPool.BLANK, //layoutUuid,
    1, 1, 1970, 0, 0, // displayDateMonth, displayDateDay, displayDateYear, 
                      // displayDateHour, displayDateMinute, 
    0, 0, 0, 0, 0, true, // expirationDateMonth, expirationDateDay, 
                         // expirationDateYear, expirationDateHour, 
                         //expirationDateMinute, neverExpire, 
    0, 0, 0, 0, 0, true, // reviewDateMonth, reviewDateDay, reviewDateYear, 
                        //reviewDateHour, reviewDateMinute, neverReview, 
    true, // indexable, 
    false, StringPool.BLANK, null, // smallImage, smallImageURL, smallImageFile, 
    null, StringPool.BLANK, // images, articleURL, 
    serviceContext
    );

works if content is a valid xml for the given structure, but doesn't if content is null or blank.

Is there is a method that returns the 'minimal' xml for a given structure, but can't find it.

Best regards, Alain

Alain Dresse
  • 673
  • 8
  • 24
  • Hi Alain, there would be a way if you could parse your structure and set a valid value for each of the dynamic-element and it's meta-data in the structure's xml. As far as I know, liferay does not do that, moreover, I'd be surprised if they do. – Ar3s Feb 04 '13 at 10:25

1 Answers1

1

I don't know of any method to do this , but this xml should suffice

<?xml version="1.0"?>

<root available-locales="en_US" default-locale="en_US">
    <static-content language-id="en_US"><![CDATA[ ]]></static-content>
</root>
maximede
  • 1,763
  • 14
  • 24
  • 1
    Thanks for your reply. This indeed creates a journal article, but without structure. I need that structure. For the moment, I hard code the XML, but need to review it whenever the structure changes. It is this latter dependency that I want to avoid. – Alain Dresse Sep 12 '13 at 02:58