Skip to content

Commit c7dd06a

Browse files
committed
LUT-25199 : Improved management of concurrent access when editing a page
1 parent 4dd579e commit c7dd06a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/java/fr/paris/lutece/plugins/wiki/web/WikiDynamicInputs.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535

3636

3737
import com.fasterxml.jackson.databind.ObjectMapper;
38-
import com.google.gson.Gson;
39-
import com.google.gson.GsonBuilder;
4038
import fr.paris.lutece.api.user.User;
4139
import fr.paris.lutece.plugins.wiki.business.*;
4240
import fr.paris.lutece.plugins.wiki.service.ContentDeserializer;
@@ -154,16 +152,18 @@ public static HttpServletResponse modifyPage( HttpServletRequest request, HttpSe
154152
*/
155153
public static void updateLastModifyAttemptPage( HttpServletRequest request ) throws IOException, UserNotSignedException
156154
{
157-
StringBuilder sb = new StringBuilder( );
158-
BufferedReader reader = request.getReader( );
155+
StringBuilder sb = new StringBuilder();
156+
BufferedReader reader = request.getReader();
159157
String line;
160-
while ( ( line = reader.readLine( ) ) != null )
161-
{
162-
sb.append( line );
158+
while ((line = reader.readLine()) != null) {
159+
sb.append(line);
163160
}
164-
String requestBody = sb.toString( );
165-
final Gson gson = new GsonBuilder( ).setPrettyPrinting( ).create( );
166-
final int topicId = gson.fromJson( requestBody, int.class );
161+
String requestBody = sb.toString();
162+
// delete the first and last character of the string to parse an int
163+
requestBody = requestBody.substring(1);
164+
requestBody = requestBody.substring(0, requestBody.length() - 1);
165+
final int topicId = Integer.parseInt(requestBody);
166+
// parse
167167
Topic topic = TopicHome.findByPrimaryKey( topicId );
168168
try
169169
{
@@ -179,7 +179,7 @@ public static void updateLastModifyAttemptPage( HttpServletRequest request ) thr
179179
}
180180
catch( Exception e )
181181
{
182-
AppLogService.error( "Error saving last user opening modify topic page", e );
182+
AppLogService.error( "Error saving last user editing topic page", e );
183183

184184
}
185185
}

0 commit comments

Comments
 (0)