org.liquibase
diff --git a/src/main/java/edu/tamu/scholars/middleware/MiddlewareApplication.java b/src/main/java/edu/tamu/scholars/middleware/MiddlewareApplication.java
index 12827bc21..e5040f65b 100644
--- a/src/main/java/edu/tamu/scholars/middleware/MiddlewareApplication.java
+++ b/src/main/java/edu/tamu/scholars/middleware/MiddlewareApplication.java
@@ -5,20 +5,27 @@
import static edu.tamu.scholars.middleware.auth.AuthConstants.PASSWORD_MIN_LENGTH;
import static edu.tamu.scholars.middleware.discovery.DiscoveryConstants.EXPORT_INDIVIDUAL_KEY;
-import java.util.TimeZone;
-
import javax.annotation.PostConstruct;
+import java.util.TimeZone;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
import edu.tamu.scholars.middleware.auth.config.AuthConfig;
import edu.tamu.scholars.middleware.auth.config.PasswordConfig;
import edu.tamu.scholars.middleware.config.model.ExportConfig;
import edu.tamu.scholars.middleware.config.model.MiddlewareConfig;
+import edu.tamu.scholars.middleware.discovery.service.IndexService;
+/**
+ * Scholars middleware application and initialization.
+ *
+ * Enables {@link Scheduled} annotation used in {@link IndexService}.
+ */
@EnableScheduling
@SpringBootApplication
public class MiddlewareApplication {
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/AuthConstants.java b/src/main/java/edu/tamu/scholars/middleware/auth/AuthConstants.java
index eaec436c2..4c8ba1c0b 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/AuthConstants.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/AuthConstants.java
@@ -1,5 +1,12 @@
package edu.tamu.scholars.middleware.auth;
+import edu.tamu.scholars.middleware.MiddlewareApplication;
+import edu.tamu.scholars.middleware.auth.details.CustomUserDetails;
+
+/**
+ * Application initialized constants for use at runtime statically.
+ * These are set in {@link MiddlewareApplication} and used in {@link CustomUserDetails}.
+ */
public class AuthConstants {
public static int PASSWORD_DURATION_IN_DAYS;
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/annotation/AvailableEmail.java b/src/main/java/edu/tamu/scholars/middleware/auth/annotation/AvailableEmail.java
index eb5cc3655..f49f72e59 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/annotation/AvailableEmail.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/annotation/AvailableEmail.java
@@ -3,15 +3,19 @@
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.validation.Constraint;
-import javax.validation.Payload;
-
+import edu.tamu.scholars.middleware.auth.model.User;
import edu.tamu.scholars.middleware.auth.validator.EmailConstraintValidator;
+/**
+ * Annotation to declare validated {@link User} model email is available.
+ */
@Documented
@Target(FIELD)
@Retention(RUNTIME)
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/annotation/ValidPassword.java b/src/main/java/edu/tamu/scholars/middleware/auth/annotation/ValidPassword.java
index 615a152e8..ade60f69b 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/annotation/ValidPassword.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/annotation/ValidPassword.java
@@ -3,15 +3,19 @@
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.validation.Constraint;
-import javax.validation.Payload;
-
+import edu.tamu.scholars.middleware.auth.model.User;
import edu.tamu.scholars.middleware.auth.validator.PasswordConstraintValidator;
+/**
+ * Annotation to declare validated {@link User} model password is available.
+ */
@Documented
@Target(TYPE)
@Retention(RUNTIME)
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/config/AuthConfig.java b/src/main/java/edu/tamu/scholars/middleware/auth/config/AuthConfig.java
index a2ab268ec..0bc6dda58 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/config/AuthConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/config/AuthConfig.java
@@ -3,6 +3,12 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+/**
+ * Injectable middleware configuration to specify properties relating to
+ * authentication and authorization.
+ *
+ * See `middleware.auth` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "middleware.auth")
public class AuthConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/config/PasswordConfig.java b/src/main/java/edu/tamu/scholars/middleware/auth/config/PasswordConfig.java
index db4d563cf..c17851ac3 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/config/PasswordConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/config/PasswordConfig.java
@@ -3,6 +3,11 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+/**
+ * Injectable middleware auth configuration to specify password properties.
+ *
+ * See `middleware.auth.password` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "middleware.auth.password")
public class PasswordConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/config/TokenConfig.java b/src/main/java/edu/tamu/scholars/middleware/auth/config/TokenConfig.java
index 167b67025..0e702eed9 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/config/TokenConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/config/TokenConfig.java
@@ -3,6 +3,11 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+/**
+ * Injectable middleware auth configuration to specify token properties.
+ *
+ * See `middleware.auth.token` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "middleware.auth.token")
public class TokenConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/controller/AuthController.java b/src/main/java/edu/tamu/scholars/middleware/auth/controller/AuthController.java
index 0b241af2b..e04b30a2a 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/controller/AuthController.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/controller/AuthController.java
@@ -6,6 +6,9 @@
import edu.tamu.scholars.middleware.auth.model.User;
+/**
+ * Authentication controller returning the authenticated {@link User}.
+ */
@RestController
public class AuthController {
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/controller/RegistrationController.java b/src/main/java/edu/tamu/scholars/middleware/auth/controller/RegistrationController.java
index 841e3a286..8f8d58a04 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/controller/RegistrationController.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/controller/RegistrationController.java
@@ -2,7 +2,11 @@
import java.io.IOException;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@@ -13,10 +17,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
import edu.tamu.scholars.middleware.auth.controller.exception.RegistrationException;
import edu.tamu.scholars.middleware.auth.controller.request.Registration;
import edu.tamu.scholars.middleware.auth.model.User;
@@ -24,25 +24,46 @@
import edu.tamu.scholars.middleware.auth.validator.group.CompleteRegistration;
import edu.tamu.scholars.middleware.auth.validator.group.SubmitRegistration;
+/**
+ * {@link User} registration controller.
+ *
+ *
+ * This controller provides ability to register a {@link User} through the following sequence of requests
+ *
+ *
+ *
+ * - Submit registration request; create disabled user, send email confirmation with link and token
+ * - Confirm email registration; validate token and confirm user email
+ * - Complete registration; update and activates user
+ *
+ */
@RestController
@RequestMapping("/registration")
public class RegistrationController {
+ @Lazy
@Autowired
private RegistrationService registrationService;
@PostMapping
- public ResponseEntity submit(@RequestBody @Validated(SubmitRegistration.class) Registration registration) throws JsonProcessingException {
+ public ResponseEntity submit(
+ @RequestBody @Validated(SubmitRegistration.class) Registration registration)
+ throws JsonProcessingException {
return ResponseEntity.ok(registrationService.submit(registration));
}
@GetMapping
- public ResponseEntity confirm(@RequestParam(required = true) String key) throws JsonParseException, JsonMappingException, IOException, RegistrationException {
+ public ResponseEntity confirm(
+ @RequestParam(required = true) String key)
+ throws JsonParseException, JsonMappingException, IOException, RegistrationException {
return ResponseEntity.ok(registrationService.confirm(key));
}
@PutMapping
- public ResponseEntity complete(@RequestParam(required = true) String key, @RequestBody @Validated(CompleteRegistration.class) Registration registration) throws RegistrationException {
+ public ResponseEntity complete(
+ @RequestParam(required = true) String key,
+ @RequestBody @Validated(CompleteRegistration.class) Registration registration)
+ throws RegistrationException {
return ResponseEntity.ok(registrationService.complete(key, registration));
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/controller/advice/RegistrationAdvice.java b/src/main/java/edu/tamu/scholars/middleware/auth/controller/advice/RegistrationAdvice.java
index eb13ab695..40f86c4c1 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/controller/advice/RegistrationAdvice.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/controller/advice/RegistrationAdvice.java
@@ -10,15 +10,27 @@
import org.springframework.web.bind.annotation.RestController;
import edu.tamu.scholars.middleware.auth.controller.RegistrationController;
+import edu.tamu.scholars.middleware.auth.model.User;
+/**
+ * {@link User} registration controller advice to handle bad requests.
+ */
@RestController
@ControllerAdvice(assignableTypes = { RegistrationController.class })
public class RegistrationAdvice {
+ // TODO: add logging
+ // TODO: handle registration exception and other exceptions thrown by the RegistrationController
+
@ResponseStatus(BAD_REQUEST)
@ExceptionHandler(MethodArgumentNotValidException.class)
- public @ResponseBody String handleMethodArgumentNotValidException(MethodArgumentNotValidException exception) {
- return exception.getBindingResult().getAllErrors().get(0).getDefaultMessage();
+ public @ResponseBody String handleMethodArgumentNotValidException(
+ MethodArgumentNotValidException exception
+ ) {
+ return exception.getBindingResult()
+ .getAllErrors()
+ .get(0)
+ .getDefaultMessage();
}
@ResponseStatus(BAD_REQUEST)
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/controller/exception/RegistrationException.java b/src/main/java/edu/tamu/scholars/middleware/auth/controller/exception/RegistrationException.java
index 92889043d..fbe57c4fd 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/controller/exception/RegistrationException.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/controller/exception/RegistrationException.java
@@ -1,5 +1,11 @@
package edu.tamu.scholars.middleware.auth.controller.exception;
+import edu.tamu.scholars.middleware.auth.model.User;
+import edu.tamu.scholars.middleware.auth.service.RegistrationService;
+
+/**
+ * {@link User} registration exception used by {@link RegistrationService}.
+ */
public class RegistrationException extends Exception {
private static final long serialVersionUID = 7712767291119883628L;
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/controller/request/Registration.java b/src/main/java/edu/tamu/scholars/middleware/auth/controller/request/Registration.java
index 47545d626..a5a707494 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/controller/request/Registration.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/controller/request/Registration.java
@@ -11,22 +11,63 @@
import edu.tamu.scholars.middleware.auth.annotation.AvailableEmail;
import edu.tamu.scholars.middleware.auth.annotation.ValidPassword;
+import edu.tamu.scholars.middleware.auth.model.User;
import edu.tamu.scholars.middleware.auth.validator.group.CompleteRegistration;
import edu.tamu.scholars.middleware.auth.validator.group.SubmitRegistration;
+/**
+ * {@link User} registration request DTO with validation of two forms; submit and complete requests.
+ */
@ValidPassword(groups = CompleteRegistration.class, message = "{Registration.passwordInvalid}")
public class Registration {
- @Size(min = 2, max = 64, groups = { SubmitRegistration.class, CompleteRegistration.class }, message = "{Registration.firstNameSize}")
+ @Size(
+ min = 2,
+ max = 64,
+ groups = {
+ SubmitRegistration.class,
+ CompleteRegistration.class
+ },
+ message = "{Registration.firstNameSize}"
+ )
private String firstName;
- @Size(min = 2, max = 64, groups = { SubmitRegistration.class, CompleteRegistration.class }, message = "{Registration.lastNameSize}")
+ @Size(
+ min = 2,
+ max = 64,
+ groups = {
+ SubmitRegistration.class,
+ CompleteRegistration.class
+ },
+ message = "{Registration.lastNameSize}"
+ )
private String lastName;
- @NotNull(message = "{Registration.emailRequired}", groups = { SubmitRegistration.class, CompleteRegistration.class })
- @NotEmpty(message = "{Registration.emailRequired}", groups = { SubmitRegistration.class, CompleteRegistration.class })
- @AvailableEmail(groups = SubmitRegistration.class, message = "{Registration.emailAlreadyInUse}")
- @Email(message = "{Registration.emailInvalid}", groups = { SubmitRegistration.class, CompleteRegistration.class })
+ @NotNull(
+ message = "{Registration.emailRequired}",
+ groups = {
+ SubmitRegistration.class,
+ CompleteRegistration.class
+ }
+ )
+ @NotEmpty(
+ message = "{Registration.emailRequired}",
+ groups = {
+ SubmitRegistration.class,
+ CompleteRegistration.class
+ }
+ )
+ @AvailableEmail(
+ groups = SubmitRegistration.class,
+ message = "{Registration.emailAlreadyInUse}"
+ )
+ @Email(
+ message = "{Registration.emailInvalid}",
+ groups = {
+ SubmitRegistration.class,
+ CompleteRegistration.class
+ }
+ )
private String email;
@JsonInclude(NON_NULL)
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/details/CustomUserDetails.java b/src/main/java/edu/tamu/scholars/middleware/auth/details/CustomUserDetails.java
index fcfdb4898..de875aaaa 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/details/CustomUserDetails.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/details/CustomUserDetails.java
@@ -6,14 +6,16 @@
import java.util.Calendar;
import java.util.Collection;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
import edu.tamu.scholars.middleware.auth.model.User;
+/**
+ * Custom {@link UserDetails} that encapsulates the {@link User}.
+ */
public class CustomUserDetails extends User implements UserDetails {
private static final long serialVersionUID = 6674712962625174202L;
@@ -43,7 +45,10 @@ public boolean isAccountNonLocked() {
@Override
@JsonIgnore
public boolean isCredentialsNonExpired() {
- return ChronoUnit.DAYS.between(getTimestamp().toInstant(), Calendar.getInstance().toInstant()) < PASSWORD_DURATION_IN_DAYS;
+ return ChronoUnit.DAYS.between(
+ getTimestamp().toInstant(),
+ Calendar.getInstance().toInstant()
+ ) < PASSWORD_DURATION_IN_DAYS;
}
@Override
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAccessDeniedExceptionHandler.java b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAccessDeniedExceptionHandler.java
index 351dc5624..b8314011b 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAccessDeniedExceptionHandler.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAccessDeniedExceptionHandler.java
@@ -2,19 +2,27 @@
import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
-import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
+/**
+ * Spring Boot autoconfigured custom {@link AccessDeniedHandler}. Customized to
+ * return 401 status and write exception message to response.
+ */
public class CustomAccessDeniedExceptionHandler implements AccessDeniedHandler {
@Override
- public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception) throws IOException, ServletException {
+ public void handle(
+ HttpServletRequest request,
+ HttpServletResponse response,
+ AccessDeniedException exception
+ ) throws IOException, ServletException {
response.setStatus(SC_UNAUTHORIZED);
response.getWriter().write(exception.getMessage());
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationEntryPoint.java b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationEntryPoint.java
index 56a168459..c7056b986 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationEntryPoint.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationEntryPoint.java
@@ -2,19 +2,27 @@
import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
-import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
+/**
+ * Spring Boot autoconfigured custom {@link AuthenticationEntryPoint}. Customized to
+ * return 401 status and write exception message to response.
+ */
public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
@Override
- public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
+ public void commence(
+ HttpServletRequest request,
+ HttpServletResponse response,
+ AuthenticationException exception
+ ) throws IOException, ServletException {
response.setStatus(SC_UNAUTHORIZED);
response.getWriter().write(exception.getMessage());
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationFailureHandler.java b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationFailureHandler.java
index f0244c8d9..b83008d16 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationFailureHandler.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationFailureHandler.java
@@ -2,19 +2,27 @@
import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
-import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
+/**
+ * Spring Boot autoconfigured custom {@link AuthenticationFailureHandler}. Customized to
+ * return 401 status and write exception message to response.
+ */
public class CustomAuthenticationFailureHandler implements AuthenticationFailureHandler {
@Override
- public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
+ public void onAuthenticationFailure(
+ HttpServletRequest request,
+ HttpServletResponse response,
+ AuthenticationException exception
+ ) throws IOException, ServletException {
response.setStatus(SC_UNAUTHORIZED);
response.getWriter().write(exception.getMessage());
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationSuccessHandler.java b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationSuccessHandler.java
index 7023fe654..b63f1ee10 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationSuccessHandler.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomAuthenticationSuccessHandler.java
@@ -2,19 +2,22 @@
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
-import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
+import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import edu.tamu.scholars.middleware.auth.model.User;
+/**
+ * Spring Boot autoconfigured custom {@link AuthenticationSuccessHandler}. Customized to
+ * return authenticated principal as {@link User}.
+ */
public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
private ObjectMapper objectMapper;
@@ -24,9 +27,14 @@ public CustomAuthenticationSuccessHandler(ObjectMapper objectMapper) {
}
@Override
- public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
+ public void onAuthenticationSuccess(
+ HttpServletRequest request,
+ HttpServletResponse response,
+ Authentication authentication
+ ) throws IOException, ServletException {
response.setContentType(APPLICATION_JSON_VALUE);
- response.getOutputStream().write(objectMapper.writeValueAsBytes((User) authentication.getPrincipal()));
+ response.getOutputStream()
+ .write(objectMapper.writeValueAsBytes((User) authentication.getPrincipal()));
}
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomLogoutSuccessHandler.java b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomLogoutSuccessHandler.java
index 1f95cc196..3be22ebbe 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomLogoutSuccessHandler.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/handler/CustomLogoutSuccessHandler.java
@@ -1,16 +1,20 @@
package edu.tamu.scholars.middleware.auth.handler;
-import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
+/**
+ * Spring Boot autoconfigured custom {@link LogoutSuccessHandler}. Customized to
+ * return 205 status and write i18n message to response.
+ */
public class CustomLogoutSuccessHandler implements LogoutSuccessHandler {
private MessageSource messageSource;
@@ -20,9 +24,17 @@ public CustomLogoutSuccessHandler(MessageSource messageSource) {
}
@Override
- public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
+ public void onLogoutSuccess(
+ HttpServletRequest request,
+ HttpServletResponse response,
+ Authentication authentication
+ ) throws IOException, ServletException {
response.setStatus(HttpServletResponse.SC_RESET_CONTENT);
- response.getWriter().write(messageSource.getMessage("CustomLogoutSuccessHandler.success", new Object[0], LocaleContextHolder.getLocale()));
+ response.getWriter().write(messageSource.getMessage(
+ "CustomLogoutSuccessHandler.success",
+ new Object[0],
+ LocaleContextHolder.getLocale()
+ ));
response.getWriter().flush();
response.getWriter().close();
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/model/Role.java b/src/main/java/edu/tamu/scholars/middleware/auth/model/Role.java
index 23667680d..7345064f8 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/model/Role.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/model/Role.java
@@ -3,11 +3,22 @@
import java.util.HashMap;
import java.util.Map;
+/**
+ * {@link User} role enumeration used for role-based authentication defined
+ * primarily in the {@link SecurityFilterChainConfig} or controller
+ * annotations @PreAuthorize using spring expression `hasRole`.
+ */
public enum Role {
+ // NOTE: inconsistent use of enum key
+ // SecurityFilterChainConfig @PreAuthorize
+ // `.hasRole("USER")` `@PreAuthorise("hasRole('ROLE_USER')")`
+ // `.hasRole("ADMIN")` `@PreAuthorise("hasRole('ROLE_ADMIN')")`
+ // `.hasRole("SUPER_ADMIN")` `@PreAuthorise("hasRole('ROLE_SUPER_ADMIN')")`
+
ROLE_USER("User"),
ROLE_ADMIN("Administrator"),
- ROLE_SUPER_ADMIN("Super Administrator");
+ ROLE_SUPER_ADMIN("Super Administrator");
private final String value;
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/model/User.java b/src/main/java/edu/tamu/scholars/middleware/auth/model/User.java
index b9867ee9a..35f612750 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/model/User.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/model/User.java
@@ -7,11 +7,6 @@
import static javax.persistence.TemporalType.TIMESTAMP;
import static org.springframework.beans.BeanUtils.copyProperties;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
@@ -24,14 +19,24 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
-import org.hibernate.annotations.CreationTimestamp;
-import org.hibernate.annotations.UpdateTimestamp;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.UpdateTimestamp;
+
+import edu.tamu.scholars.middleware.auth.details.CustomUserDetails;
+/**
+ * Application `User` to identify, authenticate, and authorize. Encapsulated by
+ * {@link CustomUserDetails} for Spring security integration.
+ */
@Entity
@Table(name = "users")
public class User implements Serializable {
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/model/repo/UserRepo.java b/src/main/java/edu/tamu/scholars/middleware/auth/model/repo/UserRepo.java
index 5471e7993..d653cfdc0 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/model/repo/UserRepo.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/model/repo/UserRepo.java
@@ -7,6 +7,11 @@
import edu.tamu.scholars.middleware.auth.model.User;
+/**
+ * {@link User} JPA repository with Long identifier. Suppress Spring DATA Rest
+ * controller endpoints to find user by email or that the email exists in
+ * system.
+ */
public interface UserRepo extends JpaRepository {
@RestResource(exported = false)
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/model/repo/handler/UserEventHandler.java b/src/main/java/edu/tamu/scholars/middleware/auth/model/repo/handler/UserEventHandler.java
index d9f314e22..6a1caafdb 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/model/repo/handler/UserEventHandler.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/model/repo/handler/UserEventHandler.java
@@ -10,6 +10,9 @@
import edu.tamu.scholars.middleware.messaging.DeleteEntityMessage;
import edu.tamu.scholars.middleware.messaging.UpdateEntityMessage;
+/**
+ * {@link User} persistance event handler dispatching user update and delete events.
+ */
@RepositoryEventHandler(User.class)
public class UserEventHandler {
@@ -21,13 +24,24 @@ public class UserEventHandler {
@HandleAfterSave
public void broadcastUserUpdate(User user) {
simpMessageTemplate.convertAndSend(USERS_CHANNEL, new UpdateEntityMessage(user));
- simpMessageTemplate.convertAndSendToUser(user.getEmail(), USERS_CHANNEL, new UpdateEntityMessage(user));
+ simpMessageTemplate.convertAndSendToUser(
+ user.getEmail(),
+ USERS_CHANNEL,
+ new UpdateEntityMessage(user)
+ );
}
@HandleAfterDelete
public void broadcastUserDelete(User user) {
- simpMessageTemplate.convertAndSend(USERS_CHANNEL, new DeleteEntityMessage(user.getEmail()));
- simpMessageTemplate.convertAndSendToUser(user.getEmail(), USERS_CHANNEL, new DeleteEntityMessage(user.getEmail()));
+ simpMessageTemplate.convertAndSend(
+ USERS_CHANNEL,
+ new DeleteEntityMessage(user.getEmail())
+ );
+ simpMessageTemplate.convertAndSendToUser(
+ user.getEmail(),
+ USERS_CHANNEL,
+ new DeleteEntityMessage(user.getEmail())
+ );
}
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/service/CustomUserDetailsService.java b/src/main/java/edu/tamu/scholars/middleware/auth/service/CustomUserDetailsService.java
index 22ff4ede8..5be3905ca 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/service/CustomUserDetailsService.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/service/CustomUserDetailsService.java
@@ -14,6 +14,11 @@
import edu.tamu.scholars.middleware.auth.model.User;
import edu.tamu.scholars.middleware.auth.model.repo.UserRepo;
+/**
+ * Spring Boot autoconfigured custom {@link UserDetailsService}. Customized to
+ * load a {@link CustomUserDetails} from a persisted {@link User} into the
+ * Spring security context for an authenticated principle.
+ */
@Service
public class CustomUserDetailsService implements UserDetailsService {
@@ -29,7 +34,10 @@ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx
if (user.isPresent()) {
return new CustomUserDetails(user.get());
}
- throw new UsernameNotFoundException(messageSource.getMessage("CustomUserDetailsService.emailNotFound", new Object[] { username }, LocaleContextHolder.getLocale()));
+ throw new UsernameNotFoundException(messageSource.getMessage(
+ "CustomUserDetailsService.emailNotFound",
+ new Object[] { username },
+ LocaleContextHolder.getLocale()));
}
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/service/RegistrationService.java b/src/main/java/edu/tamu/scholars/middleware/auth/service/RegistrationService.java
index 2dffa3a52..3e32a9389 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/service/RegistrationService.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/service/RegistrationService.java
@@ -7,6 +7,10 @@
import java.util.Calendar;
import java.util.Optional;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
@@ -16,11 +20,6 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
import edu.tamu.scholars.middleware.auth.config.AuthConfig;
import edu.tamu.scholars.middleware.auth.controller.exception.RegistrationException;
import edu.tamu.scholars.middleware.auth.controller.request.Registration;
@@ -31,6 +30,9 @@
import edu.tamu.scholars.middleware.service.EmailService;
import edu.tamu.scholars.middleware.service.TemplateService;
+/**
+ * {@link User} registration service for processing registration requests.
+ */
@Service
public class RegistrationService {
@@ -56,7 +58,7 @@ public class RegistrationService {
private ObjectMapper objectMapper;
@Autowired
- protected BCryptPasswordEncoder bCryptPasswordEncoder;
+ protected BCryptPasswordEncoder passwordEncoder;
@Autowired
private SimpMessagingTemplate simpMessageTemplate;
@@ -64,14 +66,20 @@ public class RegistrationService {
public Registration submit(Registration registration) throws JsonProcessingException {
String registrationJson = objectMapper.writeValueAsString(registration);
Token token = tokenService.allocateToken(registrationJson);
- String subject = messageSource.getMessage("RegistrationService.confirmationEmailSubject", new Object[0], LocaleContextHolder.getLocale());
+ String subject = messageSource.getMessage(
+ "RegistrationService.confirmationEmailSubject",
+ new Object[0],
+ LocaleContextHolder.getLocale()
+ );
String message = templateService.templateConfirmRegistrationMessage(registration, token.getKey());
createUser(registration);
emailService.send(registration.getEmail(), subject, message);
+
return registration;
}
- public Registration confirm(String key) throws JsonParseException, JsonMappingException, IOException, RegistrationException {
+ public Registration confirm(String key)
+ throws JsonParseException, JsonMappingException, IOException, RegistrationException {
Token token = tokenService.verifyToken(key);
String registrationJson = token.getExtendedInformation();
Registration registration = objectMapper.readValue(registrationJson, Registration.class);
@@ -83,12 +91,24 @@ public Registration confirm(String key) throws JsonParseException, JsonMappingEx
userRepo.save(user.get());
return registration;
}
- throw new RegistrationException(messageSource.getMessage("RegistrationService.emailAlreadyConfirmed", new Object[] { registration.getEmail() }, LocaleContextHolder.getLocale()));
+ throw new RegistrationException(messageSource.getMessage(
+ "RegistrationService.emailAlreadyConfirmed",
+ new Object[] { registration.getEmail() },
+ LocaleContextHolder.getLocale()
+ ));
}
userRepo.delete(user.get());
- throw new RegistrationException(messageSource.getMessage("RegistrationService.tokenExpired", new Object[0], LocaleContextHolder.getLocale()));
+ throw new RegistrationException(messageSource.getMessage(
+ "RegistrationService.tokenExpired",
+ new Object[0],
+ LocaleContextHolder.getLocale()
+ ));
}
- throw new RegistrationException(messageSource.getMessage("RegistrationService.unableToConfirmEmailNotFound", new Object[] { registration.getEmail() }, LocaleContextHolder.getLocale()));
+ throw new RegistrationException(messageSource.getMessage(
+ "RegistrationService.unableToConfirmEmailNotFound",
+ new Object[] { registration.getEmail() },
+ LocaleContextHolder.getLocale()
+ ));
}
public User complete(String key, Registration registration) throws RegistrationException {
@@ -98,15 +118,27 @@ public User complete(String key, Registration registration) throws RegistrationE
if (!isTokenExpired(token)) {
if (user.get().isConfirmed()) {
user.get().setEnabled(true);
- user.get().setPassword(bCryptPasswordEncoder.encode(registration.getPassword()));
+ user.get().setPassword(passwordEncoder.encode(registration.getPassword()));
return userRepo.save(user.get());
}
- throw new RegistrationException(messageSource.getMessage("RegistrationService.emailNotConfirmed", new Object[] { registration.getEmail() }, LocaleContextHolder.getLocale()));
+ throw new RegistrationException(messageSource.getMessage(
+ "RegistrationService.emailNotConfirmed",
+ new Object[] { registration.getEmail() },
+ LocaleContextHolder.getLocale()
+ ));
}
userRepo.delete(user.get());
- throw new RegistrationException(messageSource.getMessage("RegistrationService.tokenExpired", new Object[0], LocaleContextHolder.getLocale()));
+ throw new RegistrationException(messageSource.getMessage(
+ "RegistrationService.tokenExpired",
+ new Object[0],
+ LocaleContextHolder.getLocale()
+ ));
}
- throw new RegistrationException(messageSource.getMessage("RegistrationService.unableToCompleteEmailNotFound", new Object[] { registration.getEmail() }, LocaleContextHolder.getLocale()));
+ throw new RegistrationException(messageSource.getMessage(
+ "RegistrationService.unableToCompleteEmailNotFound",
+ new Object[] { registration.getEmail() },
+ LocaleContextHolder.getLocale()
+ ));
}
private synchronized void createUser(Registration registration) {
@@ -126,7 +158,11 @@ private boolean isTokenExpired(Token token) {
Calendar currentTime = Calendar.getInstance();
Calendar creationTime = Calendar.getInstance();
creationTime.setTimeInMillis(token.getKeyCreationTime());
- return ChronoUnit.DAYS.between(creationTime.toInstant(), currentTime.toInstant()) >= authConfig.getRegistrationTokenDuration();
+
+ return ChronoUnit.DAYS.between(
+ creationTime.toInstant(),
+ currentTime.toInstant()
+ ) >= authConfig.getRegistrationTokenDuration();
}
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/validator/EmailConstraintValidator.java b/src/main/java/edu/tamu/scholars/middleware/auth/validator/EmailConstraintValidator.java
index 5e7e48558..d7210aff0 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/validator/EmailConstraintValidator.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/validator/EmailConstraintValidator.java
@@ -6,8 +6,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import edu.tamu.scholars.middleware.auth.annotation.AvailableEmail;
+import edu.tamu.scholars.middleware.auth.model.User;
import edu.tamu.scholars.middleware.auth.model.repo.UserRepo;
+/**
+ * {@link User} email validator. Valid when email does not exist, otherwise invalid.
+ */
public class EmailConstraintValidator implements ConstraintValidator {
@Autowired
@@ -15,10 +19,7 @@ public class EmailConstraintValidator implements ConstraintValidator {
@Autowired
@@ -76,7 +79,11 @@ public boolean isValid(Registration registration, ConstraintValidatorContext con
List passwordReferences;
if (user.isPresent()) {
- passwordReferences = user.get().getOldPasswords().stream().map(pw -> new HistoricalReference(pw)).collect(Collectors.toList());
+ passwordReferences = user.get()
+ .getOldPasswords()
+ .stream()
+ .map(pw -> new HistoricalReference(pw))
+ .collect(Collectors.toList());
} else {
passwordReferences = new ArrayList();
}
@@ -89,12 +96,19 @@ public boolean isValid(Registration registration, ConstraintValidatorContext con
return true;
}
context.disableDefaultConstraintViolation();
- context.buildConstraintViolationWithTemplate(String.join(", ", validator.getMessages(result))).addConstraintViolation();
+ context.buildConstraintViolationWithTemplate(String.join(", ", validator.getMessages(result)))
+ .addConstraintViolation();
+
return false;
}
context.disableDefaultConstraintViolation();
- context.buildConstraintViolationWithTemplate(messageSource.getMessage("Registration.passwordsDoNotMatch", new Object[0], LocaleContextHolder.getLocale())).addConstraintViolation();
+ context.buildConstraintViolationWithTemplate(messageSource.getMessage(
+ "Registration.passwordsDoNotMatch",
+ new Object[0],
+ LocaleContextHolder.getLocale()
+ )).addConstraintViolation();
+
return false;
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/validator/group/CompleteRegistration.java b/src/main/java/edu/tamu/scholars/middleware/auth/validator/group/CompleteRegistration.java
index 6e51f2b0f..496318c0f 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/validator/group/CompleteRegistration.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/validator/group/CompleteRegistration.java
@@ -1,5 +1,12 @@
package edu.tamu.scholars.middleware.auth.validator.group;
+import edu.tamu.scholars.middleware.auth.controller.RegistrationController;
+
+/**
+ * Used for validation of {@link Registration} for
+ * {@link RegistrationController} to allow process to invoke `complete` of
+ * {@link RegistrationService}.
+ */
public interface CompleteRegistration {
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/auth/validator/group/SubmitRegistration.java b/src/main/java/edu/tamu/scholars/middleware/auth/validator/group/SubmitRegistration.java
index 06f97342d..43126adb1 100644
--- a/src/main/java/edu/tamu/scholars/middleware/auth/validator/group/SubmitRegistration.java
+++ b/src/main/java/edu/tamu/scholars/middleware/auth/validator/group/SubmitRegistration.java
@@ -1,5 +1,10 @@
package edu.tamu.scholars.middleware.auth.validator.group;
+/**
+ * Used for validation of {@link Registration} for
+ * {@link RegistrationController} to allow process to invoke `submit` of
+ * {@link RegistrationService}.
+ */
public interface SubmitRegistration {
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/AsyncConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/AsyncConfig.java
index 0920fc093..d241740b6 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/AsyncConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/AsyncConfig.java
@@ -4,11 +4,17 @@
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
+/**
+ * Configuration for asynchronous behaviors.
+ *
+ * Enables {@link Async} annotation not in use.
+ */
@EnableAsync
@Configuration
public class AsyncConfig implements AsyncConfigurer {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/CacheConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/CacheConfig.java
index 900163203..aadcaf63d 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/CacheConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/CacheConfig.java
@@ -1,8 +1,16 @@
package edu.tamu.scholars.middleware.config;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
+import edu.tamu.scholars.middleware.service.ResourceService;
+
+/**
+ * Configuration for caching behaviors.
+ *
+ * Enables {@link Cacheable} annotation used in {@link ResourceService}.
+ */
@EnableCaching
@Configuration
public class CacheConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/HarvesterDependencyConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/HarvesterDependencyConfig.java
index ef1309f57..7b1775423 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/HarvesterDependencyConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/HarvesterDependencyConfig.java
@@ -11,6 +11,11 @@
import edu.tamu.scholars.middleware.config.model.TriplestoreConfig;
import edu.tamu.scholars.middleware.service.Triplestore;
+/**
+ * Externally configured triplestore for harvesting.
+ *
+ * See {@link TriplestoreConfig}.
+ */
@Configuration
@Profile("!test")
public class HarvesterDependencyConfig {
@@ -19,8 +24,14 @@ public class HarvesterDependencyConfig {
private MiddlewareConfig middleware;
@Bean
- public Triplestore triplestore() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- return middleware.getTriplestore().getType().getConstructor(TriplestoreConfig.class).newInstance(middleware.getTriplestore());
+ public Triplestore triplestore()
+ throws InstantiationException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, NoSuchMethodException, SecurityException {
+
+ return middleware.getTriplestore()
+ .getType()
+ .getConstructor(TriplestoreConfig.class)
+ .newInstance(middleware.getTriplestore());
}
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/HarvestingConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/HarvestingConfig.java
index 4bf92344f..c44a2a897 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/HarvestingConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/HarvestingConfig.java
@@ -14,6 +14,11 @@
import edu.tamu.scholars.middleware.discovery.component.Harvester;
import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
+/**
+ * Externally configured list of @{link Harvester} beans.
+ *
+ * See {@link MiddlewareConfig}.
+ */
@Configuration
public class HarvestingConfig {
@@ -24,7 +29,9 @@ public class HarvestingConfig {
private AutowireCapableBeanFactory beanFactory;
@Bean
- public List harvesters() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ public List harvesters()
+ throws InstantiationException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, NoSuchMethodException, SecurityException {
List harvesters = new ArrayList();
for (HarvesterConfig config : middleware.getHarvesters()) {
for (Class extends AbstractIndexDocument> documentType : config.getDocumentTypes()) {
@@ -34,7 +41,9 @@ public List harvesters() throws InstantiationException, IllegalAccess
return harvesters;
}
- public Harvester harvester(Class extends Harvester> type, Class extends AbstractIndexDocument> documentType) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ public Harvester harvester(Class extends Harvester> type, Class extends AbstractIndexDocument> documentType)
+ throws InstantiationException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, NoSuchMethodException, SecurityException {
Harvester harvester = type.getConstructor(Class.class).newInstance(documentType);
beanFactory.autowireBean(harvester);
return harvester;
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/IndexingConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/IndexingConfig.java
index ebcf4445c..6de543167 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/IndexingConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/IndexingConfig.java
@@ -14,6 +14,9 @@
import edu.tamu.scholars.middleware.discovery.component.Indexer;
import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
+/**
+ * Externally configured list of @{link Indexer} beans.
+ */
@Configuration
public class IndexingConfig {
@@ -24,7 +27,9 @@ public class IndexingConfig {
private AutowireCapableBeanFactory beanFactory;
@Bean
- public List indexers() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ public List indexers()
+ throws InstantiationException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, NoSuchMethodException, SecurityException {
List indexers = new ArrayList();
for (IndexerConfig config : middleware.getIndexers()) {
for (Class extends AbstractIndexDocument> documentType : config.getDocumentTypes()) {
@@ -34,7 +39,9 @@ public List indexers() throws InstantiationException, IllegalAccessExce
return indexers;
}
- public Indexer indexer(Class extends Indexer> type, Class extends AbstractIndexDocument> documentType) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ public Indexer indexer(Class extends Indexer> type, Class extends AbstractIndexDocument> documentType)
+ throws InstantiationException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, NoSuchMethodException, SecurityException {
Indexer indexer = type.getConstructor(Class.class).newInstance(documentType);
beanFactory.autowireBean(indexer);
return indexer;
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/InternationalizationConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/InternationalizationConfig.java
index 28e73ed7f..155c84db1 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/InternationalizationConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/InternationalizationConfig.java
@@ -5,6 +5,9 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
+/**
+ * i18n configuration beans. Creates {@link MessageSource} bean to provide i18n keys.
+ */
@Configuration
public class InternationalizationConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/RepositoryRestConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/RepositoryRestConfig.java
index 18b555791..ea3356deb 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/RepositoryRestConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/RepositoryRestConfig.java
@@ -8,6 +8,9 @@
import edu.tamu.scholars.middleware.auth.model.repo.handler.UserEventHandler;
import edu.tamu.scholars.middleware.theme.model.repo.handler.ThemeEventHandler;
+/**
+ *
+ */
@Configuration
public class RepositoryRestConfig implements RepositoryRestConfigurer {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/SecurityExpressionConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/SecurityExpressionConfig.java
index 43b685376..a9142a0ba 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/SecurityExpressionConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/SecurityExpressionConfig.java
@@ -10,6 +10,9 @@
import org.springframework.security.web.FilterInvocation;
import org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler;
+/**
+ *
+ */
@Configuration
public class SecurityExpressionConfig {
@@ -22,17 +25,19 @@ public RoleHierarchy roleHierarchy() {
@Bean
public SecurityExpressionHandler securityExpressionHandler() {
- DefaultWebSecurityExpressionHandler securityExpressionHandler = new DefaultWebSecurityExpressionHandler();
- securityExpressionHandler.setRoleHierarchy(roleHierarchy());
- return securityExpressionHandler;
+ DefaultWebSecurityExpressionHandler seh = new DefaultWebSecurityExpressionHandler();
+ seh.setRoleHierarchy(roleHierarchy());
+
+ return seh;
}
@Bean
@SuppressWarnings({ "rawtypes", "unchecked" })
public SecurityExpressionHandler> messageSecurityExpressionHandler() {
- DefaultMessageSecurityExpressionHandler securityExpressionHandler = new DefaultMessageSecurityExpressionHandler>();
- securityExpressionHandler.setRoleHierarchy(roleHierarchy());
- return securityExpressionHandler;
+ DefaultMessageSecurityExpressionHandler seh = new DefaultMessageSecurityExpressionHandler>();
+ seh.setRoleHierarchy(roleHierarchy());
+
+ return seh;
}
private String buildRoleHierarchy() {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/SolrConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/SolrConfig.java
index 3568ba2d1..9c48bf2f8 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/SolrConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/SolrConfig.java
@@ -7,6 +7,9 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
+/**
+ *
+ */
@Configuration
@Profile("!test")
public class SolrConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/WebMvcConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/WebMvcConfig.java
index 62bc30897..761b78ab7 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/WebMvcConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/WebMvcConfig.java
@@ -24,6 +24,9 @@
import edu.tamu.scholars.middleware.discovery.resolver.QueryArgumentResolver;
import edu.tamu.scholars.middleware.export.resolver.ExportArgumentResolver;
+/**
+ *
+ */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@@ -42,7 +45,8 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/file/**")
.addResourceLocations(assetDir)
.resourceChain(true)
- .addResolver(new PathResourceResolver() {
+ .addResolver(
+ new PathResourceResolver() {
@Override
@Nullable
@@ -77,8 +81,8 @@ protected Resource getResource(String resourcePath, Resource location) throws IO
return location;
}
-
- });
+ }
+ );
}
@Override
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/WebSecurityConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/WebSecurityConfig.java
index c40faede7..5a37ee25e 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/WebSecurityConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/WebSecurityConfig.java
@@ -10,6 +10,7 @@
import java.security.SecureRandom;
import java.util.Arrays;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
@@ -36,8 +37,6 @@
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
import edu.tamu.scholars.middleware.auth.config.TokenConfig;
import edu.tamu.scholars.middleware.auth.handler.CustomAccessDeniedExceptionHandler;
import edu.tamu.scholars.middleware.auth.handler.CustomAuthenticationEntryPoint;
@@ -46,6 +45,9 @@
import edu.tamu.scholars.middleware.auth.handler.CustomLogoutSuccessHandler;
import edu.tamu.scholars.middleware.config.model.MiddlewareConfig;
+/**
+ *
+ */
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
@@ -95,8 +97,6 @@ public TokenService tokenService() throws NoSuchAlgorithmException {
@Bean
public CorsFilter corsFilter() {
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
-
CorsConfiguration embedConfig = new CorsConfiguration();
embedConfig.setAllowCredentials(true);
embedConfig.setAllowedOriginPatterns(Arrays.asList("*"));
@@ -105,17 +105,28 @@ public CorsFilter corsFilter() {
embedConfig.addAllowedMethod("GET");
embedConfig.addAllowedMethod("OPTION");
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/displayViews/search/findByName", embedConfig);
-
source.registerCorsConfiguration("/individual/{id}", embedConfig);
-
source.registerCorsConfiguration("/individual/search/findByIdIn", embedConfig);
CorsConfiguration primaryConfig = new CorsConfiguration();
primaryConfig.setAllowCredentials(true);
primaryConfig.setAllowedOrigins(config.getAllowedOrigins());
- primaryConfig.setAllowedMethods(Arrays.asList("GET", "DELETE", "PUT", "POST", "PATCH", "OPTIONS"));
- primaryConfig.setAllowedHeaders(Arrays.asList("Authorization", "Origin", "Content-Type", "Content-Disposition"));
+ primaryConfig.setAllowedMethods(Arrays.asList(
+ "GET",
+ "DELETE",
+ "PUT",
+ "POST",
+ "PATCH",
+ "OPTIONS"
+ ));
+ primaryConfig.setAllowedHeaders(Arrays.asList(
+ "Authorization",
+ "Origin",
+ "Content-Type",
+ "Content-Disposition"
+ ));
primaryConfig.setExposedHeaders(Arrays.asList("Content-Disposition"));
// NOTE: most general path must be last
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/WebSocketConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/WebSocketConfig.java
index f39b04e69..bddf06a26 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/WebSocketConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/WebSocketConfig.java
@@ -21,6 +21,9 @@
import edu.tamu.scholars.middleware.config.model.MiddlewareConfig;
import edu.tamu.scholars.middleware.messaging.handler.CustomStompSubProtocolErrorHandler;
+/**
+ *
+ */
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractSessionWebSocketMessageBrokerConfigurer {
@@ -38,11 +41,17 @@ protected void configureStompEndpoints(StompEndpointRegistry registry) {
.setAllowedOrigins(config.getAllowedOrigins().toArray(new String[config.getAllowedOrigins().size()]))
.addInterceptors(
new HttpSessionHandshakeInterceptor(),
- // TODO: remove when patched in spring-session, https://github.com/spring-projects/spring-session/issues/561
+ // TODO: remove when patched in spring-session
+ // https://github.com/spring-projects/spring-session/issues/561
new HandshakeInterceptor() {
@Override
- public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map attributes) throws Exception {
+ public boolean beforeHandshake(
+ ServerHttpRequest request,
+ ServerHttpResponse response,
+ WebSocketHandler wsHandler,
+ Map attributes
+ ) throws Exception {
if (attributes.containsKey(HTTP_SESSION_ID_ATTR_NAME)) {
attributes.put(SPRING_SESSION_ID_ATTR_NAME, attributes.get(HTTP_SESSION_ID_ATTR_NAME));
}
@@ -50,7 +59,12 @@ public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse res
}
@Override
- public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, @Nullable Exception exception) {
+ public void afterHandshake(
+ ServerHttpRequest request,
+ ServerHttpResponse response,
+ WebSocketHandler wsHandler,
+ @Nullable Exception exception
+ ) {
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/WebSocketSecurityConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/WebSocketSecurityConfig.java
index 0bd757e1b..15af29877 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/WebSocketSecurityConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/WebSocketSecurityConfig.java
@@ -13,6 +13,9 @@
import org.springframework.security.config.annotation.web.messaging.MessageSecurityMetadataSourceRegistry;
import org.springframework.security.config.annotation.web.socket.AbstractSecurityWebSocketMessageBrokerConfigurer;
+/**
+ *
+ */
@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/ExportConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/ExportConfig.java
index e6b86391c..91f78d688 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/ExportConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/ExportConfig.java
@@ -3,6 +3,11 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+/**
+ * Injectable middleware configuration to specify export properties.
+ *
+ * See `middleware.export` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "middleware.export")
public class ExportConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/HarvesterConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/HarvesterConfig.java
index eacb2f8ad..3a809f396 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/HarvesterConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/HarvesterConfig.java
@@ -3,6 +3,11 @@
import edu.tamu.scholars.middleware.discovery.component.Harvester;
import edu.tamu.scholars.middleware.discovery.component.jena.TriplestoreHarvester;
+/**
+ * {@link MiddlewareConfig} configuration to specify list of harvesters.
+ *
+ * See `middleware.harvesters` in src/main/resources/application.yml.
+ */
public class HarvesterConfig extends IndexDocumentTypesConfig {
private Class extends Harvester> type = TriplestoreHarvester.class;
@@ -10,7 +15,7 @@ public class HarvesterConfig extends IndexDocumentTypesConfig {
public HarvesterConfig() {
super();
}
-
+
public Class extends Harvester> getType() {
return type;
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/HttpConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/HttpConfig.java
index 9f02a8117..bc4c020e6 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/HttpConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/HttpConfig.java
@@ -3,6 +3,11 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+/**
+ * Injectable middleware configuration to specify http properties.
+ *
+ * See `middleware.http` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "middleware.http")
public class HttpConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/IndexConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/IndexConfig.java
index b3758b64e..2d76a6463 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/IndexConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/IndexConfig.java
@@ -3,6 +3,11 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+/**
+ * Injectable middleware configuration to specify index properties.
+ *
+ * See `middleware.index` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "middleware.index")
public class IndexConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/IndexDocumentTypesConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/IndexDocumentTypesConfig.java
index c1bf839bd..af1f0d5f6 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/IndexDocumentTypesConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/IndexDocumentTypesConfig.java
@@ -5,9 +5,12 @@
import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
+/**
+ * Inherited by {@link HarvesterConfig} and {@link IndexerConfig}.
+ */
public abstract class IndexDocumentTypesConfig {
- private List> documentTypes = new ArrayList>();
+ private List> documentTypes = new ArrayList<>();
public IndexDocumentTypesConfig() {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/IndexerConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/IndexerConfig.java
index 0859a1fda..158f19b75 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/IndexerConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/IndexerConfig.java
@@ -3,6 +3,11 @@
import edu.tamu.scholars.middleware.discovery.component.Indexer;
import edu.tamu.scholars.middleware.discovery.component.solr.SolrIndexer;
+/**
+ * {@link MiddlewareConfig} configuration to specify list of indexers.
+ *
+ * See `middleware.indexers` in src/main/resources/application.yml.
+ */
public class IndexerConfig extends IndexDocumentTypesConfig {
private Class extends Indexer> type = SolrIndexer.class;
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/MailConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/MailConfig.java
index 4fd04b2d3..5d6b704bf 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/MailConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/MailConfig.java
@@ -3,6 +3,11 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+/**
+ * Injectable middleware configuration to specify mail properties.
+ *
+ * See `middleware.mail` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "middleware.mail")
public class MailConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/MiddlewareConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/MiddlewareConfig.java
index 8d58ec692..03368a157 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/MiddlewareConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/MiddlewareConfig.java
@@ -8,6 +8,11 @@
import edu.tamu.scholars.middleware.auth.config.AuthConfig;
+/**
+ * Injectable middleware configuration.
+ *
+ * See `middleware` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "middleware")
public class MiddlewareConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/TriplestoreConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/TriplestoreConfig.java
index 191904705..98dd10ebe 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/TriplestoreConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/TriplestoreConfig.java
@@ -3,6 +3,11 @@
import edu.tamu.scholars.middleware.service.TDBTriplestore;
import edu.tamu.scholars.middleware.service.Triplestore;
+/**
+ * {@link MiddlewareConfig} configuration to specify triplestore.
+ *
+ * See `middleware.triplestore` in src/main/resources/application.yml.
+ */
public class TriplestoreConfig {
private Class extends Triplestore> type = TDBTriplestore.class;
@@ -23,9 +28,9 @@ public class TriplestoreConfig {
private int jdbcFetchSize = 8;
- private boolean streamGraphAPI = true;
+ private boolean streamGraphApi = true;
- private boolean annotateGeneratedSQL = false;
+ private boolean annotateGeneratedSql = false;
public TriplestoreConfig() {
@@ -103,20 +108,20 @@ public void setJdbcFetchSize(int jdbcFetchSize) {
this.jdbcFetchSize = jdbcFetchSize;
}
- public boolean isStreamGraphAPI() {
- return streamGraphAPI;
+ public boolean isStreamGraphApi() {
+ return streamGraphApi;
}
- public void setStreamGraphAPI(boolean streamGraphAPI) {
- this.streamGraphAPI = streamGraphAPI;
+ public void setStreamGraphApi(boolean streamGraphApi) {
+ this.streamGraphApi = streamGraphApi;
}
- public boolean isAnnotateGeneratedSQL() {
- return annotateGeneratedSQL;
+ public boolean isAnnotateGeneratedSql() {
+ return annotateGeneratedSql;
}
- public void setAnnotateGeneratedSQL(boolean annotateGeneratedSQL) {
- this.annotateGeneratedSQL = annotateGeneratedSQL;
+ public void setAnnotateGeneratedSql(boolean annotateGeneratedSql) {
+ this.annotateGeneratedSql = annotateGeneratedSql;
}
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/config/model/VivoConfig.java b/src/main/java/edu/tamu/scholars/middleware/config/model/VivoConfig.java
index 2dbf865ca..4607f9fa6 100644
--- a/src/main/java/edu/tamu/scholars/middleware/config/model/VivoConfig.java
+++ b/src/main/java/edu/tamu/scholars/middleware/config/model/VivoConfig.java
@@ -3,6 +3,11 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+/**
+ * Injectable middleware configuration to specify vivo properties.
+ *
+ * See `vivo` in src/main/resources/application.yml.
+ */
@Component
@ConfigurationProperties(prefix = "vivo")
public class VivoConfig {
diff --git a/src/main/java/edu/tamu/scholars/middleware/defaults/AbstractDefaults.java b/src/main/java/edu/tamu/scholars/middleware/defaults/AbstractDefaults.java
index 41fb30492..f5cc51da3 100644
--- a/src/main/java/edu/tamu/scholars/middleware/defaults/AbstractDefaults.java
+++ b/src/main/java/edu/tamu/scholars/middleware/defaults/AbstractDefaults.java
@@ -8,6 +8,8 @@
import java.util.Map;
import java.util.Optional;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -16,13 +18,13 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-
import edu.tamu.scholars.middleware.config.model.MiddlewareConfig;
import edu.tamu.scholars.middleware.model.Named;
import edu.tamu.scholars.middleware.model.repo.NamedRepo;
+/**
+ *
+ */
public abstract class AbstractDefaults> implements Defaults {
private static final String CREATED_DEFAULTS = "Created {} {} defaults.";
diff --git a/src/main/java/edu/tamu/scholars/middleware/defaults/AnalyticViewsDefaults.java b/src/main/java/edu/tamu/scholars/middleware/defaults/AnalyticViewsDefaults.java
index b9f574712..7dacae62c 100644
--- a/src/main/java/edu/tamu/scholars/middleware/defaults/AnalyticViewsDefaults.java
+++ b/src/main/java/edu/tamu/scholars/middleware/defaults/AnalyticViewsDefaults.java
@@ -4,13 +4,15 @@
import java.io.InputStream;
import java.util.List;
-import org.springframework.stereotype.Service;
-
import com.fasterxml.jackson.core.type.TypeReference;
+import org.springframework.stereotype.Service;
import edu.tamu.scholars.middleware.view.model.DataAndAnalyticsView;
import edu.tamu.scholars.middleware.view.model.repo.DataAndAnalyticsViewRepo;
+/**
+ *
+ */
@Service
public class AnalyticViewsDefaults extends AbstractDefaults {
diff --git a/src/main/java/edu/tamu/scholars/middleware/defaults/Defaults.java b/src/main/java/edu/tamu/scholars/middleware/defaults/Defaults.java
index 3c35b643b..8cb7ddde4 100644
--- a/src/main/java/edu/tamu/scholars/middleware/defaults/Defaults.java
+++ b/src/main/java/edu/tamu/scholars/middleware/defaults/Defaults.java
@@ -7,6 +7,9 @@
import edu.tamu.scholars.middleware.model.Named;
import edu.tamu.scholars.middleware.model.repo.NamedRepo;
+/**
+ *
+ */
public interface Defaults> {
public String path();
diff --git a/src/main/java/edu/tamu/scholars/middleware/defaults/DefaultsService.java b/src/main/java/edu/tamu/scholars/middleware/defaults/DefaultsService.java
index 6904cc2af..9fce21518 100644
--- a/src/main/java/edu/tamu/scholars/middleware/defaults/DefaultsService.java
+++ b/src/main/java/edu/tamu/scholars/middleware/defaults/DefaultsService.java
@@ -1,16 +1,19 @@
package edu.tamu.scholars.middleware.defaults;
+import javax.annotation.PostConstruct;
+
import java.io.IOException;
import java.util.List;
-import javax.annotation.PostConstruct;
-
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import edu.tamu.scholars.middleware.config.model.MiddlewareConfig;
+/**
+ *
+ */
@Service
@Profile("!test")
public class DefaultsService {
diff --git a/src/main/java/edu/tamu/scholars/middleware/defaults/DirectoryViewsDefaults.java b/src/main/java/edu/tamu/scholars/middleware/defaults/DirectoryViewsDefaults.java
index c5cb64f9d..9026e006a 100644
--- a/src/main/java/edu/tamu/scholars/middleware/defaults/DirectoryViewsDefaults.java
+++ b/src/main/java/edu/tamu/scholars/middleware/defaults/DirectoryViewsDefaults.java
@@ -4,13 +4,15 @@
import java.io.InputStream;
import java.util.List;
-import org.springframework.stereotype.Service;
-
import com.fasterxml.jackson.core.type.TypeReference;
+import org.springframework.stereotype.Service;
import edu.tamu.scholars.middleware.view.model.DirectoryView;
import edu.tamu.scholars.middleware.view.model.repo.DirectoryViewRepo;
+/**
+ *
+ */
@Service
public class DirectoryViewsDefaults extends AbstractDefaults {
diff --git a/src/main/java/edu/tamu/scholars/middleware/defaults/DiscoveryViewsDefaults.java b/src/main/java/edu/tamu/scholars/middleware/defaults/DiscoveryViewsDefaults.java
index 287f6db6a..e43509007 100644
--- a/src/main/java/edu/tamu/scholars/middleware/defaults/DiscoveryViewsDefaults.java
+++ b/src/main/java/edu/tamu/scholars/middleware/defaults/DiscoveryViewsDefaults.java
@@ -4,13 +4,15 @@
import java.io.InputStream;
import java.util.List;
-import org.springframework.stereotype.Service;
-
import com.fasterxml.jackson.core.type.TypeReference;
+import org.springframework.stereotype.Service;
import edu.tamu.scholars.middleware.view.model.DiscoveryView;
import edu.tamu.scholars.middleware.view.model.repo.DiscoveryViewRepo;
+/**
+ *
+ */
@Service
public class DiscoveryViewsDefaults extends AbstractDefaults {
diff --git a/src/main/java/edu/tamu/scholars/middleware/defaults/DisplayViewDefaults.java b/src/main/java/edu/tamu/scholars/middleware/defaults/DisplayViewDefaults.java
index 7d4e36173..4a615eafe 100644
--- a/src/main/java/edu/tamu/scholars/middleware/defaults/DisplayViewDefaults.java
+++ b/src/main/java/edu/tamu/scholars/middleware/defaults/DisplayViewDefaults.java
@@ -5,19 +5,21 @@
import java.nio.charset.StandardCharsets;
import java.util.List;
+import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
-import com.fasterxml.jackson.core.type.TypeReference;
-
-import edu.tamu.scholars.middleware.view.model.DisplaySubsectionView;
import edu.tamu.scholars.middleware.view.model.DisplaySectionView;
+import edu.tamu.scholars.middleware.view.model.DisplaySubsectionView;
import edu.tamu.scholars.middleware.view.model.DisplayTabView;
import edu.tamu.scholars.middleware.view.model.DisplayView;
import edu.tamu.scholars.middleware.view.model.ExportView;
import edu.tamu.scholars.middleware.view.model.repo.DisplayViewRepo;
+/**
+ *
+ */
@Service
public class DisplayViewDefaults extends AbstractDefaults {
diff --git a/src/main/java/edu/tamu/scholars/middleware/defaults/ThemeDefaults.java b/src/main/java/edu/tamu/scholars/middleware/defaults/ThemeDefaults.java
index 1010bf74e..961e9a48d 100644
--- a/src/main/java/edu/tamu/scholars/middleware/defaults/ThemeDefaults.java
+++ b/src/main/java/edu/tamu/scholars/middleware/defaults/ThemeDefaults.java
@@ -4,13 +4,15 @@
import java.io.InputStream;
import java.util.List;
-import org.springframework.stereotype.Service;
-
import com.fasterxml.jackson.core.type.TypeReference;
+import org.springframework.stereotype.Service;
import edu.tamu.scholars.middleware.theme.model.Theme;
import edu.tamu.scholars.middleware.theme.model.repo.ThemeRepo;
+/**
+ *
+ */
@Service
public class ThemeDefaults extends AbstractDefaults {
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/DiscoveryConstants.java b/src/main/java/edu/tamu/scholars/middleware/discovery/DiscoveryConstants.java
index 0e7f2ec00..eeb3885ae 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/DiscoveryConstants.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/DiscoveryConstants.java
@@ -1,5 +1,8 @@
package edu.tamu.scholars.middleware.discovery;
+/**
+ *
+ */
public class DiscoveryConstants {
public static String EXPORT_INDIVIDUAL_KEY;
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/advice/DiscoveryControllerAdvice.java b/src/main/java/edu/tamu/scholars/middleware/discovery/advice/DiscoveryControllerAdvice.java
index 6067e4e13..dd3fe75bd 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/advice/DiscoveryControllerAdvice.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/advice/DiscoveryControllerAdvice.java
@@ -13,6 +13,9 @@
import edu.tamu.scholars.middleware.discovery.exception.InvalidValuePathException;
import edu.tamu.scholars.middleware.discovery.exception.SolrRequestException;
+/**
+ *
+ */
@ControllerAdvice
public class DiscoveryControllerAdvice {
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/CollectionSource.java b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/CollectionSource.java
index 17f1950fd..1ddc22af8 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/CollectionSource.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/CollectionSource.java
@@ -7,6 +7,9 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ */
@Documented
@Target(TYPE)
@Retention(RUNTIME)
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/FieldSource.java b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/FieldSource.java
index 8476734f1..2b8cfefed 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/FieldSource.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/FieldSource.java
@@ -7,6 +7,9 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ */
@Documented
@Target(FIELD)
@Retention(RUNTIME)
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/FieldType.java b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/FieldType.java
index bf52b5f88..b96f53054 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/FieldType.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/FieldType.java
@@ -6,6 +6,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+/**
+ *
+ */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD, ElementType.ANNOTATION_TYPE })
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/NestedMultiValuedProperty.java b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/NestedMultiValuedProperty.java
index 5fb0c95f7..08d57024f 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/NestedMultiValuedProperty.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/NestedMultiValuedProperty.java
@@ -7,6 +7,9 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ *
+ */
@Documented
@Target(FIELD)
@Retention(RUNTIME)
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/NestedObject.java b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/NestedObject.java
index 3d5c26907..bfd0b6a45 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/NestedObject.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/annotation/NestedObject.java
@@ -9,6 +9,9 @@
import org.springframework.core.annotation.AliasFor;
+/**
+ *
+ */
@Documented
@Target(FIELD)
@Retention(RUNTIME)
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/BoostArg.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/BoostArg.java
index 03116ee07..3adff4f16 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/BoostArg.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/BoostArg.java
@@ -2,6 +2,9 @@
import edu.tamu.scholars.middleware.discovery.utility.DiscoveryUtility;
+/**
+ *
+ */
public class BoostArg {
private final String field;
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryAcademicAgeDescriptor.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryAcademicAgeDescriptor.java
index 3f705fac1..9354d868d 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryAcademicAgeDescriptor.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryAcademicAgeDescriptor.java
@@ -4,6 +4,9 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ *
+ */
// TODO: refactor to DiscoveryAcademicAgeDescriptorArg and add argument resolver
public class DiscoveryAcademicAgeDescriptor {
@@ -79,7 +82,8 @@ public List getLabeledRanges() {
int bound = getUpperLimitInYears() + getGroupingIntervalInYears();
- int i = 0, o = 0;
+ int i = 0;
+ int o = 0;
int prevStart = i;
int nextStart;
while (i <= bound) {
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryNetworkDescriptor.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryNetworkDescriptor.java
index 37892b5ee..eb5f2938d 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryNetworkDescriptor.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryNetworkDescriptor.java
@@ -11,6 +11,9 @@
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams;
+/**
+ *
+ */
// TODO: refactor to DiscoveryNetworkDescriptorArg and add argument resolver
public class DiscoveryNetworkDescriptor {
@@ -72,7 +75,12 @@ public SolrParams getSolrParams() {
return new MapSolrParams(queryParamMap);
}
- public static DiscoveryNetworkDescriptor of(String id, String dateField, List dataFields, String typeFilter) {
+ public static DiscoveryNetworkDescriptor of(
+ String id,
+ String dateField,
+ List dataFields,
+ String typeFilter
+ ) {
return new DiscoveryNetworkDescriptor(id, dateField, dataFields, typeFilter);
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryQuantityDistributionDescriptor.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryQuantityDistributionDescriptor.java
index 7d35c0e22..85bc13010 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryQuantityDistributionDescriptor.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/DiscoveryQuantityDistributionDescriptor.java
@@ -1,5 +1,8 @@
package edu.tamu.scholars.middleware.discovery.argument;
+/**
+ *
+ */
// TODO: refactor to DiscoveryQuantityDistributionDescriptorArg and add argument resolver
public class DiscoveryQuantityDistributionDescriptor {
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FacetArg.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FacetArg.java
index 1a6e9c7f7..ee987c6f3 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FacetArg.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FacetArg.java
@@ -7,6 +7,9 @@
import edu.tamu.scholars.middleware.discovery.utility.DiscoveryUtility;
import edu.tamu.scholars.middleware.view.model.FacetType;
+/**
+ *
+ */
public class FacetArg {
private final String field;
@@ -27,7 +30,17 @@ public class FacetArg {
private final String rangeGap;
- FacetArg(String field, String sort, int pageSize, int pageNumber, String type, String exclusionTag, String rangeStart, String rangeEnd, String rangeGap) {
+ FacetArg(
+ String field,
+ String sort,
+ int pageSize,
+ int pageNumber,
+ String type,
+ String exclusionTag,
+ String rangeStart,
+ String rangeEnd,
+ String rangeGap
+ ) {
this.field = DiscoveryUtility.findProperty(field);
this.sort = FacetSortArg.of(sort);
this.pageSize = pageSize;
@@ -79,7 +92,17 @@ public String getCommand() {
return StringUtils.isEmpty(exclusionTag) ? field : String.format("{!ex=%s}%s", exclusionTag, field);
}
- public static FacetArg of(String field, Optional sort, Optional pageSize, Optional pageNumber, Optional type, Optional exclusionTag, Optional rangeStart, Optional rangeEnd, Optional rangeGap) {
+ public static FacetArg of(
+ String field,
+ Optional sort,
+ Optional pageSize,
+ Optional pageNumber,
+ Optional type,
+ Optional exclusionTag,
+ Optional rangeStart,
+ Optional rangeEnd,
+ Optional rangeGap
+ ) {
String sortParam = sort.isPresent() ? sort.get() : "COUNT,DESC";
int pageSizeParam = pageSize.isPresent() ? Integer.valueOf(pageSize.get()) : 10;
int pageNumberParam = pageNumber.isPresent() ? Integer.valueOf(pageNumber.get()) : 1;
@@ -88,7 +111,17 @@ public static FacetArg of(String field, Optional sort, Optional
String rangeStartParam = rangeStart.isPresent() ? rangeStart.get() : "0";
String rangeEndParam = rangeEnd.isPresent() ? rangeEnd.get() : "100000";
String rangeGapParam = rangeGap.isPresent() ? rangeGap.get() : "100";
- return new FacetArg(field, sortParam, pageSizeParam, pageNumberParam, typeParam, exclusionTagParam, rangeStartParam, rangeEndParam, rangeGapParam);
+ return new FacetArg(
+ field,
+ sortParam,
+ pageSizeParam,
+ pageNumberParam,
+ typeParam,
+ exclusionTagParam,
+ rangeStartParam,
+ rangeEndParam,
+ rangeGapParam
+ );
}
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FacetSortArg.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FacetSortArg.java
index 5c3378259..43ed8de5f 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FacetSortArg.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FacetSortArg.java
@@ -4,6 +4,9 @@
import edu.tamu.scholars.middleware.view.model.FacetSort;
+/**
+ *
+ */
public class FacetSortArg {
private final FacetSort property;
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FilterArg.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FilterArg.java
index b6d3f3510..bb56a01c1 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FilterArg.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/FilterArg.java
@@ -7,6 +7,9 @@
import edu.tamu.scholars.middleware.discovery.utility.DiscoveryUtility;
import edu.tamu.scholars.middleware.model.OpKey;
+/**
+ *
+ */
public class FilterArg {
private final String field;
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/HighlightArg.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/HighlightArg.java
index 6933a38bf..f580671d2 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/HighlightArg.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/HighlightArg.java
@@ -6,6 +6,9 @@
import edu.tamu.scholars.middleware.discovery.utility.DiscoveryUtility;
+/**
+ *
+ */
public class HighlightArg {
private final String[] fields;
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/QueryArg.java b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/QueryArg.java
index 0bcca55de..d599518d2 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/argument/QueryArg.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/argument/QueryArg.java
@@ -7,6 +7,9 @@
import edu.tamu.scholars.middleware.discovery.DiscoveryConstants;
import edu.tamu.scholars.middleware.discovery.utility.DiscoveryUtility;
+/**
+ *
+ */
public class QueryArg {
private final String expression;
@@ -21,7 +24,14 @@ public class QueryArg {
private final String fields;
- QueryArg(String expression, String defaultField, String minimumShouldMatch, String queryField, String boostQuery, String fields) {
+ QueryArg(
+ String expression,
+ String defaultField,
+ String minimumShouldMatch,
+ String queryField,
+ String boostQuery,
+ String fields
+ ) {
this.expression = expression;
this.defaultField = DiscoveryUtility.processFields(defaultField);
this.minimumShouldMatch = minimumShouldMatch;
@@ -54,7 +64,14 @@ public String getFields() {
return fields;
}
- public static QueryArg of(Optional q, Optional df, Optional mm, Optional qf, Optional bq, Optional fl) {
+ public static QueryArg of(
+ Optional q,
+ Optional df,
+ Optional mm,
+ Optional qf,
+ Optional bq,
+ Optional fl
+ ) {
String expression = q.isPresent() ? q.get() : DiscoveryConstants.DEFAULT_QUERY;
String defaultField = df.isPresent() ? df.get() : StringUtils.EMPTY;
String minimumShouldMatch = mm.isPresent() ? mm.get() : StringUtils.EMPTY;
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/DiscoveryPagedResourcesAssembler.java b/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/DiscoveryPagedResourcesAssembler.java
index 3a4ce99a5..37d6b1952 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/DiscoveryPagedResourcesAssembler.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/DiscoveryPagedResourcesAssembler.java
@@ -16,15 +16,25 @@
import edu.tamu.scholars.middleware.discovery.response.DiscoveryFacetPage;
import edu.tamu.scholars.middleware.discovery.response.DiscoveryFacetPage.Facet;
+/**
+ *
+ */
@Component
public class DiscoveryPagedResourcesAssembler extends PagedResourcesAssembler {
- public DiscoveryPagedResourcesAssembler(@Nullable HateoasPageableHandlerMethodArgumentResolver resolver, @Nullable UriComponents baseUri) {
+ public DiscoveryPagedResourcesAssembler(
+ @Nullable HateoasPageableHandlerMethodArgumentResolver resolver,
+ @Nullable UriComponents baseUri
+ ) {
super(resolver, baseUri);
}
@Override
- protected , S> PagedModel createPagedModel(List resources, PagedModel.PageMetadata metadata, Page page) {
+ protected , S> PagedModel createPagedModel(
+ List resources,
+ PagedModel.PageMetadata metadata,
+ Page page
+ ) {
PagedModel pagedResource = super.createPagedModel(resources, metadata, page);
if (page instanceof DiscoveryFacetAndHighlightPage) {
return new FacetAndHightlightPagedResource(pagedResource, (DiscoveryFacetAndHighlightPage) page);
@@ -56,7 +66,10 @@ class FacetAndHightlightPagedResource, S> exten
private final List highlights;
- FacetAndHightlightPagedResource(PagedModel pagedResources, DiscoveryFacetAndHighlightPage facetAndHighlightPage) {
+ FacetAndHightlightPagedResource(
+ PagedModel pagedResources,
+ DiscoveryFacetAndHighlightPage facetAndHighlightPage
+ ) {
super(pagedResources.getContent(), pagedResources.getMetadata(), pagedResources.getLinks());
this.facets = facetAndHighlightPage.getFacets();
this.highlights = facetAndHighlightPage.getHighlights();
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/IndividualResourceAssembler.java b/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/IndividualResourceAssembler.java
index 149b7df83..697014711 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/IndividualResourceAssembler.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/IndividualResourceAssembler.java
@@ -14,6 +14,9 @@
import edu.tamu.scholars.middleware.discovery.controller.IndividualSearchController;
import edu.tamu.scholars.middleware.discovery.model.Individual;
+/**
+ *
+ */
@Component
public class IndividualResourceAssembler extends RepresentationModelAssemblerSupport {
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/model/IndividualCollectionModel.java b/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/model/IndividualCollectionModel.java
index e4c79662b..e19cc8eca 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/model/IndividualCollectionModel.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/model/IndividualCollectionModel.java
@@ -5,9 +5,16 @@
import org.springframework.hateoas.Link;
import org.springframework.lang.Nullable;
+/**
+ *
+ */
public class IndividualCollectionModel extends CollectionModel {
- public IndividualCollectionModel(Iterable content, Iterable links, @Nullable ResolvableType fallbackType) {
+ public IndividualCollectionModel(
+ Iterable content,
+ Iterable links,
+ @Nullable ResolvableType fallbackType
+ ) {
super(content, links, fallbackType);
}
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/model/IndividualModel.java b/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/model/IndividualModel.java
index f3e977ce7..c15ddf8c9 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/model/IndividualModel.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/assembler/model/IndividualModel.java
@@ -5,6 +5,9 @@
import edu.tamu.scholars.middleware.discovery.model.Individual;
+/**
+ *
+ */
public class IndividualModel extends EntityModel {
public IndividualModel(Individual individual, Iterable links) {
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/component/Harvester.java b/src/main/java/edu/tamu/scholars/middleware/discovery/component/Harvester.java
index 1302adc30..2a7f5eec7 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/component/Harvester.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/component/Harvester.java
@@ -1,9 +1,13 @@
package edu.tamu.scholars.middleware.discovery.component;
+import reactor.core.publisher.Flux;
+
import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
import edu.tamu.scholars.middleware.discovery.model.Individual;
-import reactor.core.publisher.Flux;
+/**
+ *
+ */
public interface Harvester {
public Flux harvest();
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/component/Indexer.java b/src/main/java/edu/tamu/scholars/middleware/discovery/component/Indexer.java
index 81556bfe2..e0b786dfd 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/component/Indexer.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/component/Indexer.java
@@ -5,6 +5,9 @@
import edu.tamu.scholars.middleware.discovery.model.AbstractIndexDocument;
import edu.tamu.scholars.middleware.discovery.model.Individual;
+/**
+ *
+ */
public interface Indexer {
public void init();
diff --git a/src/main/java/edu/tamu/scholars/middleware/discovery/component/jena/TriplestoreHarvester.java b/src/main/java/edu/tamu/scholars/middleware/discovery/component/jena/TriplestoreHarvester.java
index 95642cd9f..1e901d8f0 100644
--- a/src/main/java/edu/tamu/scholars/middleware/discovery/component/jena/TriplestoreHarvester.java
+++ b/src/main/java/edu/tamu/scholars/middleware/discovery/component/jena/TriplestoreHarvester.java
@@ -25,6 +25,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import reactor.core.publisher.Flux;
import edu.tamu.scholars.middleware.discovery.annotation.CollectionSource;
import edu.tamu.scholars.middleware.discovery.annotation.FieldSource;
@@ -34,8 +35,10 @@
import edu.tamu.scholars.middleware.discovery.model.Individual;
import edu.tamu.scholars.middleware.service.TemplateService;
import edu.tamu.scholars.middleware.service.Triplestore;
-import reactor.core.publisher.Flux;
+/**
+ *
+ */
public class TriplestoreHarvester implements Harvester {
private static final Logger logger = LoggerFactory.getLogger(TriplestoreHarvester.class);
@@ -99,7 +102,9 @@ public Class type() {
return type;
}
- private Individual createIndividual(String subject) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ private Individual createIndividual(String subject)
+ throws InstantiationException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, NoSuchMethodException, SecurityException {
Individual individual = new Individual();
individual.setId(parse(subject));
lookupProperties(individual, subject);
@@ -121,7 +126,12 @@ private void lookupProperties(Individual individual, String subject) {
logger.debug("Could not find values for {}", typeOp.getField().getName());
}
} catch (Exception e) {
- logger.error("Unable to populate individual {} {}: {}", type.getSimpleName(), parse(subject), e.getMessage());
+ logger.error(
+ "Unable to populate individual {} {}: {}",
+ type.getSimpleName(),
+ parse(subject),
+ e.getMessage()
+ );
logger.debug("Error populating individual", e);
}
});
@@ -184,7 +194,11 @@ private List