mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9153 Convert the discussions single post update webscript to de-lucened java backed
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29772 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -184,6 +184,7 @@ public class DiscussionServiceImpl implements DiscussionService
|
|||||||
post.setModifier((String)props.get(ContentModel.PROP_MODIFIER));
|
post.setModifier((String)props.get(ContentModel.PROP_MODIFIER));
|
||||||
post.setCreatedAt((Date)props.get(ContentModel.PROP_CREATED));
|
post.setCreatedAt((Date)props.get(ContentModel.PROP_CREATED));
|
||||||
post.setModifiedAt((Date)props.get(ContentModel.PROP_MODIFIED));
|
post.setModifiedAt((Date)props.get(ContentModel.PROP_MODIFIED));
|
||||||
|
post.setUpdatedAt((Date)props.get(ContentModel.PROP_UPDATED));
|
||||||
|
|
||||||
// Now do the discussion ones
|
// Now do the discussion ones
|
||||||
post.setTitle((String)props.get(ContentModel.PROP_TITLE));
|
post.setTitle((String)props.get(ContentModel.PROP_TITLE));
|
||||||
@@ -401,6 +402,20 @@ public class DiscussionServiceImpl implements DiscussionService
|
|||||||
writer.setEncoding("UTF-8");
|
writer.setEncoding("UTF-8");
|
||||||
writer.putContent(post.getContents());
|
writer.putContent(post.getContents());
|
||||||
|
|
||||||
|
// Mark it as having been updated
|
||||||
|
Date updatedAt = new Date();
|
||||||
|
nodeService.setProperty(nodeRef, ContentModel.PROP_UPDATED, updatedAt);
|
||||||
|
if(post instanceof PostInfoImpl)
|
||||||
|
{
|
||||||
|
((PostInfoImpl)post).setUpdatedAt(updatedAt);
|
||||||
|
((PostInfoImpl)post).setModifiedAt(updatedAt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Re-create to get the updated date
|
||||||
|
post = buildPost(nodeRef, post.getTopic(), post.getSystemName(), post.getContents());
|
||||||
|
}
|
||||||
|
|
||||||
// All done
|
// All done
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
|
@@ -426,9 +426,11 @@ public class DiscussionServiceImplTest
|
|||||||
// Check them
|
// Check them
|
||||||
assertEquals(topic.getTitle(), post.getTitle());
|
assertEquals(topic.getTitle(), post.getTitle());
|
||||||
assertEquals(contents, post.getContents());
|
assertEquals(contents, post.getContents());
|
||||||
|
assertEquals(null, post.getUpdatedAt());
|
||||||
|
|
||||||
assertEquals(null, reply.getTitle());
|
assertEquals(null, reply.getTitle());
|
||||||
assertEquals(replyContents, reply.getContents());
|
assertEquals(replyContents, reply.getContents());
|
||||||
|
assertEquals(null, reply.getUpdatedAt());
|
||||||
|
|
||||||
|
|
||||||
// Fetch and re-check
|
// Fetch and re-check
|
||||||
@@ -437,9 +439,11 @@ public class DiscussionServiceImplTest
|
|||||||
|
|
||||||
assertEquals(topic.getTitle(), post.getTitle());
|
assertEquals(topic.getTitle(), post.getTitle());
|
||||||
assertEquals(contents, post.getContents());
|
assertEquals(contents, post.getContents());
|
||||||
|
assertEquals(null, post.getUpdatedAt());
|
||||||
|
|
||||||
assertEquals(null, reply.getTitle());
|
assertEquals(null, reply.getTitle());
|
||||||
assertEquals(replyContents, reply.getContents());
|
assertEquals(replyContents, reply.getContents());
|
||||||
|
assertEquals(null, reply.getUpdatedAt());
|
||||||
|
|
||||||
|
|
||||||
// Edit them
|
// Edit them
|
||||||
@@ -461,6 +465,12 @@ public class DiscussionServiceImplTest
|
|||||||
assertEquals(rTitle, reply.getTitle());
|
assertEquals(rTitle, reply.getTitle());
|
||||||
assertEquals(rContents, reply.getContents());
|
assertEquals(rContents, reply.getContents());
|
||||||
|
|
||||||
|
// Check that the modified and updated dates were set
|
||||||
|
assertNotNull(post.getUpdatedAt());
|
||||||
|
assertNotNull(post.getModifiedAt());
|
||||||
|
assertNotNull(reply.getUpdatedAt());
|
||||||
|
assertNotNull(reply.getModifiedAt());
|
||||||
|
|
||||||
|
|
||||||
// Check the changes were taken
|
// Check the changes were taken
|
||||||
post = DISCUSSION_SERVICE.getPost(topic, post.getSystemName());
|
post = DISCUSSION_SERVICE.getPost(topic, post.getSystemName());
|
||||||
@@ -472,6 +482,12 @@ public class DiscussionServiceImplTest
|
|||||||
assertEquals(rTitle, reply.getTitle());
|
assertEquals(rTitle, reply.getTitle());
|
||||||
assertEquals(rContents, reply.getContents());
|
assertEquals(rContents, reply.getContents());
|
||||||
|
|
||||||
|
// Check that the modified and updated dates were set
|
||||||
|
assertNotNull(post.getUpdatedAt());
|
||||||
|
assertNotNull(post.getModifiedAt());
|
||||||
|
assertNotNull(reply.getUpdatedAt());
|
||||||
|
assertNotNull(reply.getModifiedAt());
|
||||||
|
|
||||||
|
|
||||||
// Remove the title from the topic manually
|
// Remove the title from the topic manually
|
||||||
String oldTitle = topic.getTitle();
|
String oldTitle = topic.getTitle();
|
||||||
|
@@ -41,6 +41,7 @@ public class PostInfoImpl implements PostInfo
|
|||||||
private String modifier;
|
private String modifier;
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
private Date modifiedAt;
|
private Date modifiedAt;
|
||||||
|
private Date updatedAt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new, empty {@link PostInfo}
|
* Creates a new, empty {@link PostInfo}
|
||||||
@@ -113,6 +114,12 @@ public class PostInfoImpl implements PostInfo
|
|||||||
return modifiedAt;
|
return modifiedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getUpdatedAt()
|
||||||
|
{
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(String title)
|
public void setTitle(String title)
|
||||||
{
|
{
|
||||||
@@ -144,4 +151,9 @@ public class PostInfoImpl implements PostInfo
|
|||||||
{
|
{
|
||||||
this.modifiedAt = modifiedAt;
|
this.modifiedAt = modifiedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Date updatedAt)
|
||||||
|
{
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -90,9 +90,8 @@ public interface PostInfo extends Serializable, PermissionCheckValue {
|
|||||||
*/
|
*/
|
||||||
Date getModifiedAt();
|
Date getModifiedAt();
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @return the Tags associated with the post
|
* @return the updated-at date and time
|
||||||
// * TODO Are posts ever tagged, or only ever topics?
|
*/
|
||||||
// */
|
Date getUpdatedAt();
|
||||||
// List<String> getTags();
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user