This commit is contained in:
Paulo Gustavo Veiga
2024-01-15 18:09:01 -08:00
parent 832e1991e5
commit 2357101b42
12 changed files with 38 additions and 118 deletions

View File

@@ -21,8 +21,8 @@ public class Application {
new SpringApplicationBuilder()
.parent(HibernateConfig.class, ServletConfig.class, CommonConfig.class, SecurityConfig.class).web(WebApplicationType.NONE)
.child(MvcAppConfig.class, MvcSecurityConfig.class, SecurityConfig.class, InterceptorsConfig.class).web(WebApplicationType.SERVLET)
.sibling(RestAppConfig.class, ServletConfig.class, InterceptorsConfig.class).web(WebApplicationType.SERVLET)
// .child(MvcAppConfig.class, MvcSecurityConfig.class, SecurityConfig.class, InterceptorsConfig.class).web(WebApplicationType.SERVLET)
.child(RestAppConfig.class, ServletConfig.class, InterceptorsConfig.class).web(WebApplicationType.SERVLET)
.run(args);
}

View File

@@ -69,7 +69,7 @@ public class LabelManagerImpl
final TypedQuery<Label> query = entityManager.createQuery("from com.wisemapping.model.Label wisemapping where title=:title and creator=:creator", Label.class);
query.setParameter("title", title);
query.setParameter("creator", user);
return query.getSingleResult();
return query.getResultList().stream().findFirst().orElse(null);
}
@Override

View File

@@ -53,9 +53,6 @@ public class RequestPropertiesInterceptor implements HandlerInterceptor {
@Value("${site.baseurl:}")
private String siteUrl;
@Value("${security.type}")
private String securityType;
@Value("${security.oauth2.google.url}")
private String googleOauth2Url;
@@ -74,7 +71,7 @@ public class RequestPropertiesInterceptor implements HandlerInterceptor {
request.setAttribute("site.homepage", siteHomepage);
request.setAttribute("site.static.js.url", siteStaticUrl);
request.setAttribute("security.type", securityType);
request.setAttribute("security.type", "db");
// If the property could not be resolved, try to infer one from the request...
if (siteUrl.isBlank()) {

View File

@@ -94,6 +94,7 @@ public class Label implements Serializable {
this.color = color;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@@ -49,7 +49,7 @@ public class LabelController extends BaseController {
private LabelService labelService;
@RequestMapping(method = RequestMethod.POST, value = "/labels", consumes = {"application/json"})
@RequestMapping(method = RequestMethod.POST, value = "/api/restfull/labels", consumes = {"application/json"})
@ResponseStatus(value = HttpStatus.CREATED)
public void createLabel(@RequestBody RestLabel restLabel, @NotNull HttpServletResponse response, @RequestParam(required = false) String title) throws WiseMappingException {
// Overwrite title if it was specified by parameter.
@@ -63,11 +63,11 @@ public class LabelController extends BaseController {
final Label label = createLabel(restLabel);
// Return the new created label ...
response.setHeader("Location", "/service/labels/" + label.getId());
response.setHeader("Location", "/api/restfull/labels/" + label.getId());
response.setHeader("ResourceId", Long.toString(label.getId()));
}
@RequestMapping(method = RequestMethod.GET, value = "/labels/", produces = {"application/json"})
@RequestMapping(method = RequestMethod.GET, value = "/api/restfull/labels/", produces = {"application/json"})
public RestLabelList retrieveList() {
final User user = Utils.getUser();
assert user != null;
@@ -75,7 +75,7 @@ public class LabelController extends BaseController {
return new RestLabelList(all);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/{id}")
@RequestMapping(method = RequestMethod.DELETE, value = "/api/restfull/labels/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteLabelById(@PathVariable int id) throws WiseMappingException {
final User user = Utils.getUser();

View File

@@ -54,7 +54,6 @@ public class LabelValidator implements Validator {
private void validateLabel(@NotNull final Label label, @NotNull final Errors errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED);
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "color", Messages.FIELD_REQUIRED);
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "iconName", Messages.FIELD_REQUIRED);
final String title = label.getTitle();
ValidatorUtils.rejectIfExceeded(
errors,

View File

@@ -7,13 +7,14 @@ spring.datasource.initialize=true
spring.main.allow-circular-references=true
spring.jpa.open-in-view=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.current_session_context_class=thread
spring.jpa.properties.hibernate.format_sql=true
spring.sql.init.mode=always
# LOG
logging.level.root=DEBUG
logging.level.root=TRACE
logging.level.org.apache.tomcat=INFO
##################################################################################
@@ -92,32 +93,6 @@ google.analytics.account=UA-XXXX
##################################################################################
google.ads.enabled=false
#######################################################################################
# Authentication Configuration Section
#######################################################################################
# Two type of security are supported:
# - db: User are stored in the database. Registration is required in advance.
# - ldap: Authentication takes place using a LDAP. In this case, security.ldap.* must be configured.
security.type=db
# LDAP Configuration properties.
security.ldap.server=ldap://localhost:389
# If anonymous password is required, change the wisemapping-security-ldap.xml removing the
security.ldap.server.user=cn=pveiga,dc=wisemapping,dc=com
security.ldap.server.password=password
security.ldap.basedn=dc=wisemapping,dc=com
# This will be concatenated as part of the DN. In this case, I will be "ou=people".
# In case this need to be changed, modify the wisemapping-security-ldap.xml.
security.ldap.subDn=ou=people
# Attribute used as authentication login (Eg: in this case, the user email will be used)
security.ldap.auth.attribute=mail
security.ldap.lastName.attribute=sn
security.ldap.firstName.attribute=givenName
#######################################################################################
# Google OAuth Authentication
#######################################################################################
@@ -150,6 +125,7 @@ security.oauth2.google.url=https//review
# Database Configuration
##################################################################################
spring.datasource.platform=hsqldb
database.base.url=/Users/veigap/
spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
spring.datasource.username=sa

View File

@@ -1 +1 @@
CREATE TABLE COLLABORATOR (
CREATE TABLE COLLABORATOR (