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


##########
app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryRemove.java:
##########
@@ -106,7 +109,7 @@ public String remove() {
                 // note to user
                 addMessage("weblogEdit.entryRemoved", entry.getTitle());
 
-                return SUCCESS;
+                return canListEntries() ? SUCCESS : SUCCESS_EDITOR;

Review Comment:
   🤖Claude: Fixed in 3430b8567. `canListEntries()` now catches the lookup 
error, logs it and falls back to `SUCCESS_EDITOR`, so the user never sees the 
confirm page again for a deleted entry. New test 
`failedRoleLookupAfterRemovingFallsBackToTheEditor`.



##########
app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Register.java:
##########
@@ -294,6 +295,21 @@ public String save() {
         return INPUT;
     }
 
+    /**
+     * Records that setup is done. The marker is a single row, so an existing
+     * one is updated rather than inserted again.
+     */
+    static void markSetupCompleted() throws WebloggerException {

Review Comment:
   🤖Claude: Fixed in 3430b8567. While setup isn't done, `save()` runs the 
registration under a lock, and the whole action runs again inside it. So a 
second submission sees setup finished and goes through the normal checks 
(registration enabled, user name taken) instead of failing on the duplicate 
key. This only covers a single server, and there's no concurrency test because 
Mockito's static mocks are per-thread.



##########
app/src/test/java/org/apache/roller/weblogger/ui/struts2/core/RegisterSetupMarkerTest.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.roller.weblogger.ui.struts2.core;
+
+import org.apache.roller.weblogger.TestUtils;
+import org.apache.roller.weblogger.business.PropertiesManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
+import org.apache.roller.weblogger.ui.core.security.BootstrapSecurity;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * Registration records that setup is done in a single properties row. Writing
+ * it when the row is already there must update it, not insert a second one,
+ * or the registration fails on the duplicate key.
+ */
+class RegisterSetupMarkerTest {
+
+    @BeforeEach
+    void setUp() throws Exception {
+        TestUtils.setupWeblogger();
+    }
+
+    @Test
+    void recordingSetupTwiceKeepsOneRow() throws Exception {
+        PropertiesManager properties = 
WebloggerFactory.getWeblogger().getPropertiesManager();
+

Review Comment:
   🤖Claude: Fixed in 3430b8567. The test saves `bootstrap.completed` and 
`users.registration.enabled` in `@BeforeEach` and restores both in 
`@AfterEach`. If the marker wasn't there before, it deletes the row over JDBC, 
since `PropertiesManager` has no remove. It also removes the users it 
registered.



##########
app/src/test/java/org/apache/roller/weblogger/ui/struts2/core/RegisterSetupMarkerTest.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.roller.weblogger.ui.struts2.core;
+
+import org.apache.roller.weblogger.TestUtils;
+import org.apache.roller.weblogger.business.PropertiesManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
+import org.apache.roller.weblogger.ui.core.security.BootstrapSecurity;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * Registration records that setup is done in a single properties row. Writing
+ * it when the row is already there must update it, not insert a second one,
+ * or the registration fails on the duplicate key.
+ */
+class RegisterSetupMarkerTest {
+
+    @BeforeEach
+    void setUp() throws Exception {
+        TestUtils.setupWeblogger();
+    }
+
+    @Test
+    void recordingSetupTwiceKeepsOneRow() throws Exception {
+        PropertiesManager properties = 
WebloggerFactory.getWeblogger().getPropertiesManager();

Review Comment:
   🤖Claude: Fixed in 3430b8567. The test now records setup, then registers two 
more users through `save()` against Derby and checks both exist. Putting the 
unconditional marker insert back into `save()` makes it fail with the 
duplicate-key error. Renamed to 
`registrationsAfterSetupIsRecordedSaveTheirUsers`.



-- 
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