Step 1: First create the site using siteService.
Step 2: Create the datalist container using siteService or SiteServiceImpl.
Step 3: Create the necessary properties for the datalist.
Step 4: Create the datalist using nodeService.
  1. String DATALIST_CONTAINER = "dataLists";
  2. SiteInfo siteInfo = this.siteService.createSite (TEST_SITE_PRESET, siteName, siteName, DESCRIPTION_TEST_THIS_IS_MY_DESCRIPTION, SiteVisibility.PRIVATE);
  3. //NodeRef dataListContainer = siteService.createContainer(siteName, DATALIST_CONTAINER, ContentModel.TYPE_CONTAINER, null);
  4. //if the datalist container does not exist then it will create a new one based on the create boolean parameter
  5. NodeRef dataListContainer = SiteServiceImpl.getSiteContainer(siteName, DATALIST_CONTAINER, true, siteService, transactionService, taggingService);
  6. Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
  7. contentProps.put(ContentModel.PROP_TITLE, "Demo");
  8. contentProps.put(ContentModel.PROP_DESCRIPTION, "Demo Datalist");
  9. contentProps.put(DataListModel.PROP_DATALIST_ITEM_TYPE, "YOUR DATALIST ITEM TYPE");
  10. nodeService.createNode(dataListContainer, ContentModel.ASSOC_CONTAINS, QName.createQName(DataListModel.DATALIST_MODEL_PREFIX, "Demo"), DataListModel.TYPE_DATALIST, contentProps);
Hope this helps someone.