aa
This commit is contained in:
@@ -9,7 +9,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.filter.CommonsRequestLoggingFilter;
|
||||||
import tech.jhipster.config.JHipsterProperties;
|
import tech.jhipster.config.JHipsterProperties;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -44,4 +46,14 @@ public class LoggingConfiguration {
|
|||||||
addContextListener(context, customFields, loggingProperties);
|
addContextListener(context, customFields, loggingProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CommonsRequestLoggingFilter requestLoggingFilter() {
|
||||||
|
CommonsRequestLoggingFilter loggingFilter = new CommonsRequestLoggingFilter();
|
||||||
|
loggingFilter.setIncludeClientInfo(true);
|
||||||
|
loggingFilter.setIncludeQueryString(true);
|
||||||
|
loggingFilter.setIncludePayload(true);
|
||||||
|
loggingFilter.setMaxPayloadLength(64000);
|
||||||
|
return loggingFilter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,26 @@
|
|||||||
package com.sasiedzi.event.web.rest;
|
package com.sasiedzi.event.web.rest;
|
||||||
|
|
||||||
import com.sasiedzi.event.domain.Registration;
|
import com.sasiedzi.event.domain.Registration;
|
||||||
|
import com.sasiedzi.event.domain.User;
|
||||||
import com.sasiedzi.event.repository.RegistrationRepository;
|
import com.sasiedzi.event.repository.RegistrationRepository;
|
||||||
|
import com.sasiedzi.event.repository.UserRepository;
|
||||||
|
import com.sasiedzi.event.service.UserService;
|
||||||
|
import com.sasiedzi.event.service.dto.AdminUserDTO;
|
||||||
import com.sasiedzi.event.web.rest.errors.BadRequestAlertException;
|
import com.sasiedzi.event.web.rest.errors.BadRequestAlertException;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.security.Principal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import tech.jhipster.web.util.HeaderUtil;
|
import tech.jhipster.web.util.HeaderUtil;
|
||||||
@@ -31,13 +38,20 @@ public class RegistrationResource {
|
|||||||
|
|
||||||
private static final String ENTITY_NAME = "registration";
|
private static final String ENTITY_NAME = "registration";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
UserService userService;
|
||||||
|
|
||||||
@Value("${jhipster.clientApp.name}")
|
@Value("${jhipster.clientApp.name}")
|
||||||
private String applicationName;
|
private String applicationName;
|
||||||
|
|
||||||
private final RegistrationRepository registrationRepository;
|
private final RegistrationRepository registrationRepository;
|
||||||
|
|
||||||
public RegistrationResource(RegistrationRepository registrationRepository) {
|
@Autowired
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
public RegistrationResource(RegistrationRepository registrationRepository, UserRepository userRepository) {
|
||||||
this.registrationRepository = registrationRepository;
|
this.registrationRepository = registrationRepository;
|
||||||
|
this.userRepository = userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,11 +62,20 @@ public class RegistrationResource {
|
|||||||
* @throws URISyntaxException if the Location URI syntax is incorrect.
|
* @throws URISyntaxException if the Location URI syntax is incorrect.
|
||||||
*/
|
*/
|
||||||
@PostMapping("")
|
@PostMapping("")
|
||||||
public ResponseEntity<Registration> createRegistration(@Valid @RequestBody Registration registration) throws URISyntaxException {
|
public ResponseEntity<Registration> createRegistration(@Valid @RequestBody Registration registration, Principal principal)
|
||||||
|
throws URISyntaxException {
|
||||||
LOG.debug("REST request to save Registration : {}", registration);
|
LOG.debug("REST request to save Registration : {}", registration);
|
||||||
|
AdminUserDTO userFromAuthentication;
|
||||||
|
if (principal instanceof AbstractAuthenticationToken) {
|
||||||
|
userFromAuthentication = userService.getUserFromAuthentication((AbstractAuthenticationToken) principal);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("User could not be found");
|
||||||
|
}
|
||||||
if (registration.getId() != null) {
|
if (registration.getId() != null) {
|
||||||
throw new BadRequestAlertException("A new registration cannot already have an ID", ENTITY_NAME, "idexists");
|
throw new BadRequestAlertException("A new registration cannot already have an ID", ENTITY_NAME, "idexists");
|
||||||
}
|
}
|
||||||
|
Optional<User> oneByLogin = userRepository.findOneByLogin(userFromAuthentication.getLogin());
|
||||||
|
registration.setUser(oneByLogin.get());
|
||||||
registration = registrationRepository.save(registration);
|
registration = registrationRepository.save(registration);
|
||||||
return ResponseEntity.created(new URI("/api/registrations/" + registration.getId()))
|
return ResponseEntity.created(new URI("/api/registrations/" + registration.getId()))
|
||||||
.headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, registration.getId().toString()))
|
.headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, registration.getId().toString()))
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ logging:
|
|||||||
tech.jhipster: DEBUG
|
tech.jhipster: DEBUG
|
||||||
org.hibernate.SQL: DEBUG
|
org.hibernate.SQL: DEBUG
|
||||||
com.sasiedzi.event: DEBUG
|
com.sasiedzi.event: DEBUG
|
||||||
|
org.springframeworkweb.filter.CommonsRequestLoggingFilter: DEBUG
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
devtools:
|
devtools:
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
ROOT: INFO
|
ROOT: DEBUG
|
||||||
tech.jhipster: INFO
|
tech.jhipster: INFO
|
||||||
com.sasiedzi.event: INFO
|
com.sasiedzi.event: DEBUG
|
||||||
|
org.springframeworkweb.filter.CommonsRequestLoggingFilter: DEBUG
|
||||||
|
|
||||||
management:
|
management:
|
||||||
prometheus:
|
prometheus:
|
||||||
|
|||||||
@@ -6,15 +6,16 @@
|
|||||||
<conversionRule conversionWord="crlf" converterClass="com.sasiedzi.event.config.CRLFLogConverter" />
|
<conversionRule conversionWord="crlf" converterClass="com.sasiedzi.event.config.CRLFLogConverter" />
|
||||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %crlf(%m){red} %n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %crlf(%m){red} %n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
<!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
|
<!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
|
||||||
<!--
|
|
||||||
<property name="FILE_LOG_PATTERN" value="${FILE_LOG_PATTERN:-%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %crlf(%m) %n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
<property name="FILE_LOG_PATTERN" value="${FILE_LOG_PATTERN:-%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %crlf(%m) %n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
-->
|
<property name="LOG_FILE" value="spring.log"/>
|
||||||
|
|
||||||
|
|
||||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
|
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
|
||||||
|
|
||||||
<!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
|
<!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
|
||||||
<!--
|
|
||||||
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
|
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
|
||||||
|
|
||||||
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
|
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
@@ -22,12 +23,13 @@
|
|||||||
<appender-ref ref="FILE"/>
|
<appender-ref ref="FILE"/>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<root level="${logging.level.root}">
|
<!-- <root level="${logging.level.root}">-->
|
||||||
<appender-ref ref="ASYNC"/>
|
<!-- <appender-ref ref="ASYNC"/>-->
|
||||||
</root>
|
<!-- </root>-->
|
||||||
-->
|
|
||||||
|
|
||||||
<logger name="com.sasiedzi.event" level="INFO"/>
|
<logger name="com.sasiedzi.event" level="INFO"/>
|
||||||
|
<logger name="org.springframework.web.filter.CommonsRequestLoggingFilter" level="DEBUG"/>
|
||||||
|
|
||||||
<logger name="javax.management" level="WARN"/>
|
<logger name="javax.management" level="WARN"/>
|
||||||
<logger name="angus.activation" level="WARN"/>
|
<logger name="angus.activation" level="WARN"/>
|
||||||
@@ -70,6 +72,7 @@
|
|||||||
<springProperty name="log.level" source="logging.level.root" defaultValue="INFO" />
|
<springProperty name="log.level" source="logging.level.root" defaultValue="INFO" />
|
||||||
<root level="${log.level}">
|
<root level="${log.level}">
|
||||||
<appender-ref ref="CONSOLE" />
|
<appender-ref ref="CONSOLE" />
|
||||||
|
<appender-ref ref="ASYNC" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
<!-- Prevent logback from outputting its own status -->
|
<!-- Prevent logback from outputting its own status -->
|
||||||
|
|||||||
Reference in New Issue
Block a user