snoopdave commented on code in PR #316:
URL: https://github.com/apache/roller/pull/316#discussion_r4608447421


##########
app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/EntryCollection.java:
##########
@@ -376,11 +387,19 @@ private void copyToRollerEntry(AtomEntry entry, 
WeblogEntry rollerEntry) throws
         rollerEntry.setPubTime(pubTime);
         rollerEntry.setUpdateTime(updateTime);
 
+        boolean wasPublished = 
PubStatus.PUBLISHED.equals(rollerEntry.getStatus());
         if (entry.isDraft()) {
             rollerEntry.setStatus(PubStatus.DRAFT);
+        } else if (pubTime.after(new Date(System.currentTimeMillis() + 
RollerConstants.MIN_IN_MS))) {
+            // like the entry editor, a publish time more than a minute ahead 
schedules the entry
+            rollerEntry.setStatus(PubStatus.SCHEDULED);
         } else {
             rollerEntry.setStatus(PubStatus.PUBLISHED);
         }
+        if (wasPublished != rollerEntry.isPublished()) {
+            // the entry's tags enter or leave the weblog's tag counts
+            rollerEntry.setRefreshAggregates(true);

Review Comment:
   **Important:** When a PUT both changes a published entry to a draft or 
scheduled entry and removes a tag, this refresh decrements only tags still on 
the entry. `removeWeblogEntryTag()` then skips the removed tag because the 
entry is no longer published, leaving its count behind. Reconcile counts using 
the tags before and after the update, and test a status change that also 
removes a tag.



##########
app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java:
##########
@@ -202,6 +202,15 @@ public void saveWeblogEntry(WeblogEntry entry) throws 
WebloggerException {
             entry.setAnchor(this.createAnchor(entry));
         }
         
+        // if the entry was published to future, set status as SCHEDULED
+        // we only consider an entry future published if it is scheduled
+        // more than 1 minute into the future; decide this before updating the
+        // tag aggregates so a scheduled entry's tags are not counted early
+        if (PubStatus.PUBLISHED.equals(entry.getStatus()) &&
+                entry.getPubTime().after(new Date(System.currentTimeMillis() + 
RollerConstants.MIN_IN_MS))) {
+            entry.setStatus(PubStatus.SCHEDULED);

Review Comment:
   **Important:** `MetaWeblogAPIHandler.editPost()` can move an existing 
published entry to a future `dateCreated` and save it without setting 
`refreshAggregates`. This changes its status to SCHEDULED here while leaving 
its tags counted. Have that caller track the previous publication state and 
request an aggregate refresh when the state changes; add a test for this path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to