Cleanup
This commit is contained in:
parent
c3c4b1202f
commit
d8c8f70ebd
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
### Spring initialzr
|
### Spring initialzr
|
||||||
HELP.md
|
HELP.md
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
### Intellij ###
|
### Intellij ###
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class BookController {
|
||||||
@RequestParam("file") MultipartFile imageFile,
|
@RequestParam("file") MultipartFile imageFile,
|
||||||
@RequestParam("author") String author,
|
@RequestParam("author") String author,
|
||||||
@RequestParam("title") String title) throws Exception {
|
@RequestParam("title") String title) throws Exception {
|
||||||
bookService.handleImageUpload(imageFile, author, title);
|
bookService.handleImageUpload(imageFile, author, title, getUserName());
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package pl.edu.amu.wmi.bookapi.api;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class SecurityInterceptor implements HandlerInterceptor {
|
|
||||||
@Override
|
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package pl.edu.amu.wmi.bookapi.api.dto;
|
|
||||||
|
|
||||||
public class PatchBookRequest {
|
|
||||||
}
|
|
|
@ -24,7 +24,7 @@ public class MessageCustomRepositoryImpl implements MessageCustomRepository {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Sort sort = Sort.by(Sort.Direction.DESC, "createdAt");
|
Sort sort = Sort.by(Sort.Direction.ASC, "createdAt");
|
||||||
|
|
||||||
return mongoTemplate.find(query.with(sort), MessageDocument.class);
|
return mongoTemplate.find(query.with(sort), MessageDocument.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String SECRET = "SecretKeyToGenJWTs";
|
public static final String SECRET = "SecretKeyToGenJWTs";
|
||||||
public static final long EXPIRATION_TIME = 864_000_000; // 10 days
|
public static final long EXPIRATION_TIME = 864_000_000;
|
||||||
public static final String TOKEN_PREFIX = "Bearer ";
|
public static final String TOKEN_PREFIX = "Bearer ";
|
||||||
public static final String HEADER_STRING = "Authorization";
|
public static final String HEADER_STRING = "Authorization";
|
||||||
public static final String SIGN_UP_URL = "/users/sign-up";
|
public static final String SIGN_UP_URL = "/users/sign-up";
|
||||||
|
|
|
@ -48,7 +48,6 @@ public class WebSecurity extends WebSecurityConfigurerAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private JWTAuthenticationFilter getConfiguredJwtAuthenticationFilter() throws Exception{
|
private JWTAuthenticationFilter getConfiguredJwtAuthenticationFilter() throws Exception{
|
||||||
System.out.println("JWT Auth");
|
|
||||||
JWTAuthenticationFilter jwtFilter = new JWTAuthenticationFilter(authenticationManager());
|
JWTAuthenticationFilter jwtFilter = new JWTAuthenticationFilter(authenticationManager());
|
||||||
jwtFilter.setFilterProcessesUrl("/users/login");
|
jwtFilter.setFilterProcessesUrl("/users/login");
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,9 @@ public class BookService {
|
||||||
bookRepository.save(BookDocument.from(userName, bookDto));
|
bookRepository.save(BookDocument.from(userName, bookDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleImageUpload(MultipartFile imageFile, String author, String title) throws Exception {
|
public void handleImageUpload(MultipartFile imageFile, String author, String title, String username) throws Exception {
|
||||||
String detectedEan = imageProcessingService.getDecodedEan(imageFile);
|
String detectedEan = imageProcessingService.getDecodedEan(imageFile);
|
||||||
saveBook(author, new BookDto(detectedEan, author, title));
|
saveBook(username, new BookDto(detectedEan, author, title));
|
||||||
if (detectedEan.isEmpty()) {
|
if (detectedEan.isEmpty()) {
|
||||||
throw new NoEanCodeDetectedException();
|
throw new NoEanCodeDetectedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import pl.edu.amu.wmi.bookapi.repositories.ThreadRepository;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class MessageService {
|
public class MessageService {
|
||||||
|
@ -28,7 +29,14 @@ public class MessageService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ThreadDocument> getThreads(String user) {
|
public List<ThreadDocument> getThreads(String user) {
|
||||||
return threadRepository.findByParticipant(user);
|
List<ThreadDocument> threads = threadRepository.findByParticipant(user);
|
||||||
|
return threads
|
||||||
|
.stream()
|
||||||
|
.map(it -> {
|
||||||
|
it.getParticipantsIds().remove(user);
|
||||||
|
return it;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MessageDocument> getMessagesInThread(String threadId, String userId) {
|
public List<MessageDocument> getMessagesInThread(String threadId, String userId) {
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
imgproc.debug = true
|
imgproc.debug = true
|
||||||
|
spring.servlet.multipart.max-file-size=3MB
|
||||||
|
spring.servlet.multipart.max-request-size=3MB
|
Loading…
Reference in New Issue