mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2025-01-05 09:33:51 +01:00
Compare commits
No commits in common. "34318c1e3f70d1efd97eb384fedc0ac797802f32" and "885de4e1c145fe1a7796f573c58aea903c71867e" have entirely different histories.
34318c1e3f
...
885de4e1c1
@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.2.2</version>
|
<version>3.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>org.wisemapping</groupId>
|
<groupId>org.wisemapping</groupId>
|
||||||
@ -199,6 +199,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.wisemapping;
|
package com.wisemapping;
|
||||||
|
|
||||||
import com.wisemapping.config.common.CommonConfig;
|
import com.wisemapping.config.common.CommonConfig;
|
||||||
|
import com.wisemapping.config.mvc.MvcAppConfig;
|
||||||
import com.wisemapping.config.rest.RestAppConfig;
|
import com.wisemapping.config.rest.RestAppConfig;
|
||||||
import org.springframework.boot.WebApplicationType;
|
import org.springframework.boot.WebApplicationType;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* 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.config.mvc;
|
||||||
|
|
||||||
|
import com.wisemapping.filter.RequestPropertiesInterceptor;
|
||||||
|
import com.wisemapping.filter.UserLocaleInterceptor;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
//@Configuration
|
||||||
|
//@ComponentScan(basePackageClasses = UserLocaleInterceptor.class)
|
||||||
|
public class InterceptorsConfig implements WebMvcConfigurer {
|
||||||
|
@Autowired
|
||||||
|
private UserLocaleInterceptor userLocaleInterceptor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RequestPropertiesInterceptor requestPropertiesInterceptor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(@NotNull final InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(userLocaleInterceptor);
|
||||||
|
registry.addInterceptor(requestPropertiesInterceptor);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.wisemapping.config.mvc;
|
||||||
|
|
||||||
|
import com.wisemapping.webmvc.MvcMindmapController;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||||
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
|
||||||
|
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||||
|
import org.springframework.web.servlet.view.JstlView;
|
||||||
|
|
||||||
|
|
||||||
|
//@SpringBootApplication
|
||||||
|
//@Import({MvcMindmapController.class, MvcSecurityConfig.class})
|
||||||
|
//@EnableWebMvc
|
||||||
|
public class MvcAppConfig implements WebMvcConfigurer {
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
registry
|
||||||
|
.addResourceHandler("/**")
|
||||||
|
.addResourceLocations("classpath:/public/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ViewResolver viewResolver() {
|
||||||
|
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
|
||||||
|
resolver.setPrefix("/WEB-INF/jsp/");
|
||||||
|
resolver.setSuffix(".jsp");
|
||||||
|
resolver.setViewClass(JstlView.class);
|
||||||
|
return resolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
HandlerExceptionResolver errorHandler() {
|
||||||
|
final SimpleMappingExceptionResolver result = new SimpleMappingExceptionResolver();
|
||||||
|
|
||||||
|
//mapping status code with view response.
|
||||||
|
result.addStatusCode("reactInclude", 403);
|
||||||
|
|
||||||
|
//setting default error view
|
||||||
|
result.setDefaultErrorView("reactInclude");
|
||||||
|
result.setDefaultStatusCode(500);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
package com.wisemapping.config.mvc;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
|
||||||
|
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
|
public class MvcSecurityConfig {
|
||||||
|
@Bean
|
||||||
|
@Order(1)
|
||||||
|
public SecurityFilterChain embeddedDisabledXOrigin(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception {
|
||||||
|
http
|
||||||
|
.securityMatchers((matchers) ->
|
||||||
|
matchers.requestMatchers(mvc.pattern("/c/maps/*/embed")))
|
||||||
|
.authorizeHttpRequests(
|
||||||
|
(auth) -> auth.requestMatchers(mvc.pattern(("/c/maps/*/embed"))).permitAll())
|
||||||
|
.headers((header -> header.frameOptions()
|
||||||
|
.disable()
|
||||||
|
))
|
||||||
|
.csrf(AbstractHttpConfigurer::disable);
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
|
||||||
|
return new MvcRequestMatcher.Builder(introspector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Order(2)
|
||||||
|
public SecurityFilterChain mvcFilterChain(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception {
|
||||||
|
http
|
||||||
|
.securityMatchers((matchers) ->
|
||||||
|
matchers.requestMatchers(mvc.pattern("/c/**")))
|
||||||
|
.authorizeHttpRequests(
|
||||||
|
(auth) ->
|
||||||
|
auth
|
||||||
|
.requestMatchers(mvc.pattern("/c/login")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/c/logout")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/c/registration")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/c/registration-success")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/c/registration-google")).permitAll()
|
||||||
|
|
||||||
|
.requestMatchers(mvc.pattern("/c/forgot-password")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/c/forgot-password-success")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/c/maps/*/try")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/c/maps/*/public")).permitAll()
|
||||||
|
.requestMatchers(mvc.pattern("/c/**")).hasAnyRole("USER", "ADMIN")
|
||||||
|
.anyRequest().authenticated())
|
||||||
|
.formLogin((loginForm) ->
|
||||||
|
loginForm.loginPage("/c/login")
|
||||||
|
.loginProcessingUrl("/c/perform-login")
|
||||||
|
.defaultSuccessUrl("/c/maps/")
|
||||||
|
.failureUrl("/c/login?login_error=2"))
|
||||||
|
.logout((logout) ->
|
||||||
|
logout
|
||||||
|
.logoutUrl("/c/logout")
|
||||||
|
.logoutSuccessUrl("/c/login")
|
||||||
|
.invalidateHttpSession(true)
|
||||||
|
.deleteCookies("JSESSIONID")
|
||||||
|
.permitAll()
|
||||||
|
).rememberMe(remember ->
|
||||||
|
remember
|
||||||
|
.tokenValiditySeconds(2419200)
|
||||||
|
.rememberMeParameter("remember-me"
|
||||||
|
)
|
||||||
|
).headers((header -> header.frameOptions()
|
||||||
|
.disable()
|
||||||
|
))
|
||||||
|
.csrf((csrf) ->
|
||||||
|
csrf.ignoringRequestMatchers(mvc.pattern("/c/logout")));
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Order(3)
|
||||||
|
public SecurityFilterChain shareResourcesFilterChain(@NotNull final HttpSecurity http, @NotNull final MvcRequestMatcher.Builder mvc) throws Exception {
|
||||||
|
return http.authorizeHttpRequests(
|
||||||
|
(auth) ->
|
||||||
|
auth.requestMatchers(mvc.pattern("/static/**")).permitAll().
|
||||||
|
requestMatchers(mvc.pattern("/css/**")).permitAll().
|
||||||
|
requestMatchers(mvc.pattern("/js/**")).permitAll().
|
||||||
|
// @todo: Why this is required ...
|
||||||
|
requestMatchers(mvc.pattern("/WEB-INF/jsp/*.jsp")).permitAll().
|
||||||
|
requestMatchers(mvc.pattern("/images/**")).permitAll().
|
||||||
|
requestMatchers(mvc.pattern("/*")).permitAll()
|
||||||
|
|
||||||
|
).build();
|
||||||
|
}
|
||||||
|
}
|
@ -54,7 +54,7 @@ public class RestAppConfig {
|
|||||||
}))
|
}))
|
||||||
.csrf(AbstractHttpConfigurer::disable)
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
.httpBasic(withDefaults())
|
// .httpBasic(withDefaults())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import java.util.Optional;
|
|||||||
@Component
|
@Component
|
||||||
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||||
private static final String BEARER_TOKEN_PREFIX = "Bearer ";
|
private static final String BEARER_TOKEN_PREFIX = "Bearer ";
|
||||||
private static final String AUTHORIZATION_HEADER = "Authorization";
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserDetailsService userDetailsService;
|
private UserDetailsService userDetailsService;
|
||||||
|
|
||||||
@ -39,6 +38,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
final Optional<String> token = getJwtTokenFromRequest(request);
|
final Optional<String> token = getJwtTokenFromRequest(request);
|
||||||
|
|
||||||
|
|
||||||
if (token.isPresent() && SecurityContextHolder.getContext().getAuthentication() == null) {
|
if (token.isPresent() && SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||||
// Extract email from token ...
|
// Extract email from token ...
|
||||||
final Optional<String> email = extractEmailFromToken(token.get());
|
final Optional<String> email = extractEmailFromToken(token.get());
|
||||||
@ -74,7 +74,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
private static Optional<String> getJwtTokenFromRequest(@NotNull HttpServletRequest request) {
|
private static Optional<String> getJwtTokenFromRequest(@NotNull HttpServletRequest request) {
|
||||||
Optional<String> result = Optional.empty();
|
Optional<String> result = Optional.empty();
|
||||||
|
|
||||||
final String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER);
|
final String authorizationHeader = request.getHeader("Authorization");
|
||||||
if (authorizationHeader != null) {
|
if (authorizationHeader != null) {
|
||||||
if (authorizationHeader.startsWith(BEARER_TOKEN_PREFIX)) {
|
if (authorizationHeader.startsWith(BEARER_TOKEN_PREFIX)) {
|
||||||
logger.trace("JWT Bearer token found.");
|
logger.trace("JWT Bearer token found.");
|
||||||
|
@ -1,33 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright [2022] [wisemapping]
|
* Copyright [2022] [wisemapping]
|
||||||
*
|
*
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the license at
|
* You may obtain a copy of the license at
|
||||||
*
|
*
|
||||||
* http://www.wisemapping.org/license
|
* http://www.wisemapping.org/license
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.wisemapping.model;
|
package com.wisemapping.model;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "COLLABORATION_PROPERTIES")
|
@Table(name = "COLLABORATION_PROPERTIES")
|
||||||
public class CollaborationProperties implements Serializable {
|
public class CollaborationProperties implements Serializable {
|
||||||
public static final String DEFAULT_JSON_PROPERTIES = "{\"zoom\":0.8}";
|
public static final String DEFAULT_JSON_PROPERTIES = "{zoom:0.8}";
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private int id;
|
private int id;
|
||||||
|
@ -24,7 +24,6 @@ import com.wisemapping.rest.model.*;
|
|||||||
import com.wisemapping.security.Utils;
|
import com.wisemapping.security.Utils;
|
||||||
import com.wisemapping.service.*;
|
import com.wisemapping.service.*;
|
||||||
import com.wisemapping.validator.MapInfoValidator;
|
import com.wisemapping.validator.MapInfoValidator;
|
||||||
import com.wisemapping.view.MindMapBean;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.validator.routines.EmailValidator;
|
import org.apache.commons.validator.routines.EmailValidator;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -73,7 +72,7 @@ public class MindmapController extends BaseController {
|
|||||||
@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = {"application/json"})
|
@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = {"application/json"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestMindmap retrieve(@PathVariable int id) throws WiseMappingException {
|
public RestMindmap retrieve(@PathVariable int id) throws WiseMappingException {
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
final Mindmap mindMap = findMindmapById(id);
|
final Mindmap mindMap = findMindmapById(id);
|
||||||
return new RestMindmap(mindMap, user);
|
return new RestMindmap(mindMap, user);
|
||||||
}
|
}
|
||||||
@ -81,28 +80,17 @@ public class MindmapController extends BaseController {
|
|||||||
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/{id}/metadata", produces = {"application/json"})
|
@RequestMapping(method = RequestMethod.GET, value = "/{id}/metadata", produces = {"application/json"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestMindmapMetadata retrieveMetadata(@PathVariable int id) throws WiseMappingException {
|
public RestMindmap retrieveMetadata(@PathVariable int id) throws WiseMappingException {
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
final Mindmap mindmap = findMindmapById(id);
|
|
||||||
final MindMapBean mindMapBean = new MindMapBean(mindmap, user);
|
final Mindmap mindMap = findMindmapById(id);
|
||||||
|
return new RestMindmap(mindMap, user);
|
||||||
// Is the mindmap locked ?.
|
|
||||||
boolean isLocked = false;
|
|
||||||
final LockManager lockManager = this.mindmapService.getLockManager();
|
|
||||||
String lockFullName = null;
|
|
||||||
if (lockManager.isLocked(mindmap) && !lockManager.isLockedBy(mindmap, user)) {
|
|
||||||
final LockInfo lockInfo = lockManager.getLockInfo(mindmap);
|
|
||||||
isLocked = true;
|
|
||||||
lockFullName = lockInfo.getUser().getFullName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RestMindmapMetadata(mindmap.getTitle(), mindMapBean.getProperties(), isLocked, lockFullName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/", produces = {"application/json"})
|
@RequestMapping(method = RequestMethod.GET, value = "/", produces = {"application/json"})
|
||||||
public RestMindmapList retrieveList(@RequestParam(required = false) String q) {
|
public RestMindmapList retrieveList(@RequestParam(required = false) String q) {
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
|
|
||||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||||
List<Mindmap> mindmaps = mindmapService.findMindmapsByUser(user);
|
List<Mindmap> mindmaps = mindmapService.findMindmapsByUser(user);
|
||||||
@ -131,7 +119,7 @@ public class MindmapController extends BaseController {
|
|||||||
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException {
|
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException {
|
||||||
|
|
||||||
final Mindmap mindmap = findMindmapById(id);
|
final Mindmap mindmap = findMindmapById(id);
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
|
|
||||||
// Validate arguments ...
|
// Validate arguments ...
|
||||||
final String properties = restMindmap.getProperties();
|
final String properties = restMindmap.getProperties();
|
||||||
@ -160,7 +148,7 @@ public class MindmapController extends BaseController {
|
|||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
public void updateRevertMindmap(@PathVariable int id, @PathVariable String hid) throws WiseMappingException, IOException {
|
public void updateRevertMindmap(@PathVariable int id, @PathVariable String hid) throws WiseMappingException, IOException {
|
||||||
final Mindmap mindmap = findMindmapById(id);
|
final Mindmap mindmap = findMindmapById(id);
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
|
|
||||||
if (LATEST_HISTORY_REVISION.equals(hid)) {
|
if (LATEST_HISTORY_REVISION.equals(hid)) {
|
||||||
// Revert to the latest stored version ...
|
// Revert to the latest stored version ...
|
||||||
@ -190,7 +178,7 @@ public class MindmapController extends BaseController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException {
|
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException {
|
||||||
final Mindmap mindmap = findMindmapById(id);
|
final Mindmap mindmap = findMindmapById(id);
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
mindmap.setXmlStr(xmlDoc);
|
mindmap.setXmlStr(xmlDoc);
|
||||||
|
|
||||||
saveMindmapDocument(false, mindmap, user);
|
saveMindmapDocument(false, mindmap, user);
|
||||||
@ -205,6 +193,7 @@ public class MindmapController extends BaseController {
|
|||||||
return mindmapHistory.getUnzipXml();
|
return mindmapHistory.getUnzipXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The intention of this method is the update of several properties at once ...
|
* The intention of this method is the update of several properties at once ...
|
||||||
*/
|
*/
|
||||||
@ -214,7 +203,7 @@ public class MindmapController extends BaseController {
|
|||||||
public void updateProperties(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
public void updateProperties(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||||
|
|
||||||
final Mindmap mindmap = findMindmapById(id);
|
final Mindmap mindmap = findMindmapById(id);
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
|
|
||||||
final String xml = restMindmap.getXml();
|
final String xml = restMindmap.getXml();
|
||||||
if (xml != null && !xml.isEmpty()) {
|
if (xml != null && !xml.isEmpty()) {
|
||||||
@ -250,7 +239,7 @@ public class MindmapController extends BaseController {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private Mindmap findMindmapById(int id) throws MapCouldNotFoundException, AccessDeniedSecurityException {
|
private Mindmap findMindmapById(int id) throws MapCouldNotFoundException, AccessDeniedSecurityException {
|
||||||
// Has enough permissions ?
|
// Has enough permissions ?
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
if (!mindmapService.hasPermissions(user, id, CollaborationRole.VIEWER)) {
|
if (!mindmapService.hasPermissions(user, id, CollaborationRole.VIEWER)) {
|
||||||
throw new AccessDeniedSecurityException(id, user);
|
throw new AccessDeniedSecurityException(id, user);
|
||||||
}
|
}
|
||||||
@ -269,7 +258,7 @@ public class MindmapController extends BaseController {
|
|||||||
public void updateTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
|
public void updateTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
|
||||||
|
|
||||||
final Mindmap mindMap = findMindmapById(id);
|
final Mindmap mindMap = findMindmapById(id);
|
||||||
final User user = Utils.getUser(true);
|
final User user = Utils.getUser();
|
||||||
|
|
||||||
// Is there a map with the same name ?
|
// Is there a map with the same name ?
|
||||||
if (mindmapService.getMindmapByTitle(title, user) != null) {
|
if (mindmapService.getMindmapByTitle(title, user) != null) {
|
||||||
|
@ -20,10 +20,18 @@ package com.wisemapping.rest.model;
|
|||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.wisemapping.exceptions.InvalidMindmapException;
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
import com.wisemapping.model.*;
|
||||||
|
import com.wisemapping.util.TimeUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
@JsonAutoDetect(
|
@JsonAutoDetect(
|
||||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||||
@ -32,47 +40,8 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
)
|
)
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class RestMindmapMetadata {
|
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) {
|
public RestMindmapMetadata() throws WiseMappingException {
|
||||||
this.jsonProps = jsonProps;
|
|
||||||
this.title = title;
|
|
||||||
this.locked = locked;
|
|
||||||
this.isLockedBy = isLockedBy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJsonProps() {
|
|
||||||
return jsonProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJsonProps(String jsonProps) {
|
|
||||||
this.jsonProps = jsonProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLocked() {
|
|
||||||
return locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocked(boolean locked) {
|
|
||||||
this.locked = locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsLockedBy() {
|
|
||||||
return isLockedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsLockedBy(String isLockedBy) {
|
|
||||||
this.isLockedBy = isLockedBy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,10 @@ public class MindMapBean {
|
|||||||
mindmap.setDescription(d);
|
mindmap.setDescription(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getXmlAsJsLiteral() throws IOException {
|
||||||
|
return this.mindmap.getXmlAsJsLiteral();
|
||||||
|
}
|
||||||
|
|
||||||
public String getProperties() throws WiseMappingException {
|
public String getProperties() throws WiseMappingException {
|
||||||
String result = null;
|
String result = null;
|
||||||
|
|
||||||
|
BIN
wise-api/src/main/resources/public/favicon.ico
Normal file
BIN
wise-api/src/main/resources/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
wise-api/src/main/resources/public/favicon.png
Normal file
BIN
wise-api/src/main/resources/public/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
6
wise-api/src/main/resources/public/index.html
Normal file
6
wise-api/src/main/resources/public/index.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta HTTP-EQUIV="REFRESH" content="0; url=c/maps/">
|
||||||
|
</head>
|
||||||
|
</html>
|
@ -22,7 +22,6 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -36,7 +35,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
private RestUser user;
|
private RestUser user;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TestRestTemplate restTemplate;
|
private TestRestTemplate restTemplate;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
@ -53,7 +52,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listMaps() throws URISyntaxException {
|
public void listMaps() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteMap() throws URISyntaxException {
|
public void deleteMap() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -104,7 +103,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void changeMapTitle() throws URISyntaxException {
|
public void changeMapTitle() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -118,7 +117,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateMapsCreation() throws URISyntaxException { // Configure media types ...
|
public void validateMapsCreation() { // Configure media types ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
requestHeaders.set(HttpHeaders.ACCEPT_LANGUAGE, "en");
|
requestHeaders.set(HttpHeaders.ACCEPT_LANGUAGE, "en");
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
@ -136,7 +135,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void changeMapDescription() throws URISyntaxException {
|
public void changeMapDescription() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -156,7 +155,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateMapXml() throws IOException, URISyntaxException { // Configure media types ...
|
public void updateMapXml() throws IOException { // Configure media types ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -184,7 +183,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cloneMap() throws IOException, URISyntaxException {
|
public void cloneMap() throws IOException {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -212,7 +211,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateStarred() throws URISyntaxException { // Configure media types ...
|
public void updateStarred() { // Configure media types ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -239,7 +238,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyMapOwnership() throws URISyntaxException {
|
public void verifyMapOwnership() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate firstUser = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate firstUser = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -267,7 +266,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateMap() throws IOException, WiseMappingException, URISyntaxException {
|
public void updateMap() throws IOException, WiseMappingException {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -304,7 +303,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addCollabs() throws URISyntaxException {
|
public void addCollabs() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -325,7 +324,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateCollabType() throws URISyntaxException {
|
public void updateCollabType() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -362,7 +361,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteCollabs() throws URISyntaxException {
|
public void deleteCollabs() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -401,7 +400,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteCollabsWithInvalidEmail() throws URISyntaxException {
|
public void deleteCollabsWithInvalidEmail() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -419,7 +418,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteCollabsWithoutOwnerPermission() throws URISyntaxException {
|
public void deleteCollabsWithoutOwnerPermission() {
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
final URI resourceUri = addNewMap(restTemplate, "deleteWithoutOwnerPermission");
|
final URI resourceUri = addNewMap(restTemplate, "deleteWithoutOwnerPermission");
|
||||||
|
|
||||||
@ -440,7 +439,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteOwnerCollab() throws URISyntaxException {
|
public void deleteOwnerCollab() {
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
// Create a sample map ...
|
// Create a sample map ...
|
||||||
@ -459,7 +458,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addCollabsInvalidOwner() throws URISyntaxException {
|
public void addCollabsInvalidOwner() {
|
||||||
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
@ -480,7 +479,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeLabelFromMindmap() throws URISyntaxException { // Configure media types ...
|
public void removeLabelFromMindmap() { // Configure media types ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -525,7 +524,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addLabelToMindmap() throws URISyntaxException { // Configure media types ...
|
public void addLabelToMindmap() { // Configure media types ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -549,23 +548,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fetchMapMetadata() throws URISyntaxException {
|
public void updateCollabs() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String mapTitle = "Maps 1 !";
|
|
||||||
final URI mindmapUri = addNewMap(restTemplate, mapTitle);
|
|
||||||
final String mapId = mindmapUri.getPath().replace("/api/restful/maps/", "");
|
|
||||||
|
|
||||||
final ResponseEntity<RestMindmapMetadata> exchange = restTemplate.exchange(mindmapUri + "/metadata", HttpMethod.GET, null, RestMindmapMetadata.class);
|
|
||||||
assertTrue(exchange.getStatusCode().is2xxSuccessful());
|
|
||||||
assertEquals(mapTitle, exchange.getBody().getTitle());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateCollabs() throws URISyntaxException {
|
|
||||||
|
|
||||||
// Create a sample map ...
|
// Create a sample map ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
@ -609,7 +592,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateProperties() throws IOException, WiseMappingException, URISyntaxException {
|
public void updateProperties() throws IOException, WiseMappingException {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -640,7 +623,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void batchDelete() throws URISyntaxException {
|
public void batchDelete() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -663,7 +646,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updatePublishState() throws URISyntaxException {
|
public void updatePublishState() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -680,7 +663,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fetchMapHistory() throws URISyntaxException {
|
public void fetchMapHistory() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -698,7 +681,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateRevertMindmap() throws IOException, URISyntaxException {
|
public void updateRevertMindmap() throws IOException {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -726,7 +709,7 @@ public class RestMindmapControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addCollabWhitoutOwnerPermission() throws URISyntaxException {
|
public void addCollabWhitoutOwnerPermission() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -753,7 +736,7 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addCollabWhitOwnerRole() throws URISyntaxException {
|
public void addCollabWhitOwnerRole() {
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
@ -817,19 +800,14 @@ public class RestMindmapControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
private URI addNewMap(@NotNull TestRestTemplate template, @NotNull String title, @Nullable String xml) throws URISyntaxException {
|
private URI addNewMap(@NotNull TestRestTemplate template, @NotNull String title, @Nullable String xml) {
|
||||||
// Create a new map ...
|
// Create a new map ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_XML);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_XML);
|
||||||
final HttpEntity<String> createUserEntity = new HttpEntity<>(xml, requestHeaders);
|
HttpEntity<String> createUserEntity = new HttpEntity<>(xml, requestHeaders);
|
||||||
|
return template.postForLocation("/api/restful/maps?title=" + title, createUserEntity);
|
||||||
final ResponseEntity<String> exchange = template.exchange("/api/restful/maps?title=" + title, HttpMethod.POST, createUserEntity, String.class);
|
|
||||||
assertTrue(exchange.getStatusCode().is2xxSuccessful());
|
|
||||||
|
|
||||||
final List<String> locations = exchange.getHeaders().get(HttpHeaders.LOCATION);
|
|
||||||
return new URI(locations.stream().findFirst().get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private URI addNewMap(@NotNull TestRestTemplate template, @NotNull String title) throws URISyntaxException {
|
private URI addNewMap(@NotNull TestRestTemplate template, @NotNull String title) {
|
||||||
return addNewMap(template, title, null);
|
return addNewMap(template, title, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user