@Override protected void doImportStagedModel(PortletDataContext portletDataContext, WikiNode node) throws Exception { long userId = portletDataContext.getUserId(node.getUserUuid()); ServiceContext serviceContext = portletDataContext.createServiceContext(node); WikiNode importedNode = null; if (portletDataContext.isDataStrategyMirror()) { WikiNode existingNode = WikiNodeLocalServiceUtil.fetchNodeByUuidAndGroupId( node.getUuid(), portletDataContext.getScopeGroupId()); String initialNodeName = PropsValues.WIKI_INITIAL_NODE_NAME; if ((existingNode == null) && initialNodeName.equals(node.getName())) { WikiNode initialNode = WikiNodeLocalServiceUtil.fetchNode( portletDataContext.getScopeGroupId(), node.getName()); if (initialNode != null) { WikiNodeLocalServiceUtil.deleteWikiNode(initialNode); } } if (existingNode == null) { serviceContext.setUuid(node.getUuid()); importedNode = WikiNodeLocalServiceUtil.addNode( userId, node.getName(), node.getDescription(), serviceContext); } else { importedNode = WikiNodeLocalServiceUtil.updateNode( existingNode.getNodeId(), node.getName(), node.getDescription(), serviceContext); } } else { String initialNodeName = PropsValues.WIKI_INITIAL_NODE_NAME; if (initialNodeName.equals(node.getName())) { WikiNode initialNode = WikiNodeLocalServiceUtil.fetchNode( portletDataContext.getScopeGroupId(), node.getName()); if (initialNode != null) { WikiNodeLocalServiceUtil.deleteWikiNode(initialNode); } } String nodeName = getNodeName(portletDataContext, node, node.getName(), 2); importedNode = WikiNodeLocalServiceUtil.addNode(userId, nodeName, node.getDescription(), serviceContext); } portletDataContext.importClassedModel(node, importedNode); }
public String getNodePagesRSS( long nodeId, int max, String type, double version, String displayStyle, String feedURL, String entryURL) throws PortalException, SystemException { WikiNodePermission.check(getPermissionChecker(), nodeId, ActionKeys.VIEW); WikiNode node = wikiNodePersistence.findByPrimaryKey(nodeId); long companyId = node.getCompanyId(); String name = node.getName(); String description = node.getDescription(); List<WikiPage> pages = getNodePages(nodeId, max); boolean diff = false; Locale locale = null; return exportToRSS( companyId, name, description, type, version, displayStyle, feedURL, entryURL, pages, diff, locale); }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); WikiNode newWikiNode = _persistence.create(pk); newWikiNode.setUuid(RandomTestUtil.randomString()); newWikiNode.setGroupId(RandomTestUtil.nextLong()); newWikiNode.setCompanyId(RandomTestUtil.nextLong()); newWikiNode.setUserId(RandomTestUtil.nextLong()); newWikiNode.setUserName(RandomTestUtil.randomString()); newWikiNode.setCreateDate(RandomTestUtil.nextDate()); newWikiNode.setModifiedDate(RandomTestUtil.nextDate()); newWikiNode.setName(RandomTestUtil.randomString()); newWikiNode.setDescription(RandomTestUtil.randomString()); newWikiNode.setLastPostDate(RandomTestUtil.nextDate()); newWikiNode.setStatus(RandomTestUtil.nextInt()); newWikiNode.setStatusByUserId(RandomTestUtil.nextLong()); newWikiNode.setStatusByUserName(RandomTestUtil.randomString()); newWikiNode.setStatusDate(RandomTestUtil.nextDate()); _persistence.update(newWikiNode); WikiNode existingWikiNode = _persistence.findByPrimaryKey(newWikiNode.getPrimaryKey()); Assert.assertEquals(existingWikiNode.getUuid(), newWikiNode.getUuid()); Assert.assertEquals(existingWikiNode.getNodeId(), newWikiNode.getNodeId()); Assert.assertEquals(existingWikiNode.getGroupId(), newWikiNode.getGroupId()); Assert.assertEquals(existingWikiNode.getCompanyId(), newWikiNode.getCompanyId()); Assert.assertEquals(existingWikiNode.getUserId(), newWikiNode.getUserId()); Assert.assertEquals(existingWikiNode.getUserName(), newWikiNode.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingWikiNode.getCreateDate()), Time.getShortTimestamp(newWikiNode.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingWikiNode.getModifiedDate()), Time.getShortTimestamp(newWikiNode.getModifiedDate())); Assert.assertEquals(existingWikiNode.getName(), newWikiNode.getName()); Assert.assertEquals(existingWikiNode.getDescription(), newWikiNode.getDescription()); Assert.assertEquals( Time.getShortTimestamp(existingWikiNode.getLastPostDate()), Time.getShortTimestamp(newWikiNode.getLastPostDate())); Assert.assertEquals(existingWikiNode.getStatus(), newWikiNode.getStatus()); Assert.assertEquals(existingWikiNode.getStatusByUserId(), newWikiNode.getStatusByUserId()); Assert.assertEquals(existingWikiNode.getStatusByUserName(), newWikiNode.getStatusByUserName()); Assert.assertEquals( Time.getShortTimestamp(existingWikiNode.getStatusDate()), Time.getShortTimestamp(newWikiNode.getStatusDate())); }