From 34318c1e3f70d1efd97eb384fedc0ac797802f32 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Fri, 9 Feb 2024 00:02:56 -0800 Subject: [PATCH] Fix json props. --- .../filter/JwtAuthenticationFilter.java | 4 +- .../model/CollaborationProperties.java | 37 ++++++++++--------- .../wisemapping/rest/MindmapController.java | 2 - .../rest/model/RestMindmapMetadata.java | 26 ++++++------- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/wise-api/src/main/java/com/wisemapping/filter/JwtAuthenticationFilter.java b/wise-api/src/main/java/com/wisemapping/filter/JwtAuthenticationFilter.java index fe462d9d..9b376273 100644 --- a/wise-api/src/main/java/com/wisemapping/filter/JwtAuthenticationFilter.java +++ b/wise-api/src/main/java/com/wisemapping/filter/JwtAuthenticationFilter.java @@ -25,6 +25,7 @@ import java.util.Optional; @Component public class JwtAuthenticationFilter extends OncePerRequestFilter { private static final String BEARER_TOKEN_PREFIX = "Bearer "; + private static final String AUTHORIZATION_HEADER = "Authorization"; @Autowired private UserDetailsService userDetailsService; @@ -38,7 +39,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { throws ServletException, IOException { final Optional token = getJwtTokenFromRequest(request); - if (token.isPresent() && SecurityContextHolder.getContext().getAuthentication() == null) { // Extract email from token ... final Optional email = extractEmailFromToken(token.get()); @@ -74,7 +74,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { private static Optional getJwtTokenFromRequest(@NotNull HttpServletRequest request) { Optional result = Optional.empty(); - final String authorizationHeader = request.getHeader("Authorization"); + final String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null) { if (authorizationHeader.startsWith(BEARER_TOKEN_PREFIX)) { logger.trace("JWT Bearer token found."); diff --git a/wise-api/src/main/java/com/wisemapping/model/CollaborationProperties.java b/wise-api/src/main/java/com/wisemapping/model/CollaborationProperties.java index 155c4b82..5dc578e7 100644 --- a/wise-api/src/main/java/com/wisemapping/model/CollaborationProperties.java +++ b/wise-api/src/main/java/com/wisemapping/model/CollaborationProperties.java @@ -1,32 +1,33 @@ /* -* Copyright [2022] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* 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. -*/ + * Copyright [2022] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * 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 com.wisemapping.model; import org.jetbrains.annotations.NotNull; import jakarta.persistence.*; + import java.io.Serializable; @Entity @Table(name = "COLLABORATION_PROPERTIES") -public class CollaborationProperties implements Serializable { - public static final String DEFAULT_JSON_PROPERTIES = "{zoom:0.8}"; +public class CollaborationProperties implements Serializable { + public static final String DEFAULT_JSON_PROPERTIES = "{\"zoom\":0.8}"; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; diff --git a/wise-api/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-api/src/main/java/com/wisemapping/rest/MindmapController.java index b1d1df7d..2d308c2b 100644 --- a/wise-api/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-api/src/main/java/com/wisemapping/rest/MindmapController.java @@ -33,7 +33,6 @@ import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; @@ -206,7 +205,6 @@ public class MindmapController extends BaseController { return mindmapHistory.getUnzipXml(); } - /** * The intention of this method is the update of several properties at once ... */ diff --git a/wise-api/src/main/java/com/wisemapping/rest/model/RestMindmapMetadata.java b/wise-api/src/main/java/com/wisemapping/rest/model/RestMindmapMetadata.java index 050cf876..8b44850b 100644 --- a/wise-api/src/main/java/com/wisemapping/rest/model/RestMindmapMetadata.java +++ b/wise-api/src/main/java/com/wisemapping/rest/model/RestMindmapMetadata.java @@ -35,6 +35,14 @@ public class RestMindmapMetadata { private String jsonProps; private boolean locked; private String title; + private String isLockedBy; + + public RestMindmapMetadata(@NotNull String title, @NotNull String jsonProps, boolean locked, @Nullable String isLockedBy) { + this.jsonProps = jsonProps; + this.title = title; + this.locked = locked; + this.isLockedBy = isLockedBy; + } public String getJsonProps() { return jsonProps; @@ -60,21 +68,11 @@ public class RestMindmapMetadata { this.title = title; } - public String getLockFullName() { - return lockFullName; + public String getIsLockedBy() { + return isLockedBy; } - public void setLockFullName(String lockFullName) { - this.lockFullName = lockFullName; + public void setIsLockedBy(String isLockedBy) { + this.isLockedBy = isLockedBy; } - - private String lockFullName; - - public RestMindmapMetadata(@NotNull String title, @NotNull String jsonProps, boolean locked, @Nullable String lockFullName) { - this.jsonProps = jsonProps; - this.title = title; - this.locked = locked; - this.lockFullName = lockFullName; - } - }