diff --git a/auth/pom.xml b/auth/pom.xml index 30444ea6..5e7a119b 100644 --- a/auth/pom.xml +++ b/auth/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT @@ -20,25 +20,25 @@ edu.tamu.weaver core - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT edu.tamu.weaver user - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT edu.tamu.weaver token - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT edu.tamu.weaver email - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/auth/src/main/java/edu/tamu/weaver/auth/AuthConstants.java b/auth/src/main/java/edu/tamu/weaver/auth/AuthConstants.java index ecc4982e..ebe006f0 100644 --- a/auth/src/main/java/edu/tamu/weaver/auth/AuthConstants.java +++ b/auth/src/main/java/edu/tamu/weaver/auth/AuthConstants.java @@ -29,9 +29,11 @@ public class AuthConstants { public final static byte[] ERROR_RESPONSE; public final static byte[] UNAUTHORIZED_RESPONSE; - + public final static ApiResponse UNAUTHORIZED_API_RESPONSE = new ApiResponse(UNAUTHORIZED); + public final static ApiResponse SERVER_ERROR_API_RESPONSE = new ApiResponse(ERROR); + static { ObjectMapper objectMapper = new ObjectMapper(); byte[] expiredResponse = new byte[0]; diff --git a/auth/src/main/java/edu/tamu/weaver/auth/controller/handler/AuthRestExceptionHandler.java b/auth/src/main/java/edu/tamu/weaver/auth/controller/handler/AuthRestExceptionHandler.java index 0f30a2fe..3d33a8ca 100644 --- a/auth/src/main/java/edu/tamu/weaver/auth/controller/handler/AuthRestExceptionHandler.java +++ b/auth/src/main/java/edu/tamu/weaver/auth/controller/handler/AuthRestExceptionHandler.java @@ -10,7 +10,10 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import edu.tamu.weaver.auth.exception.CredentialsNotFoundException; +import edu.tamu.weaver.auth.exception.UserNotFoundException; import edu.tamu.weaver.response.ApiResponse; +import edu.tamu.weaver.response.ApiStatus; @RestController @ControllerAdvice @@ -19,8 +22,21 @@ public class AuthRestExceptionHandler { @ExceptionHandler(AccessDeniedException.class) @ResponseStatus(value = HttpStatus.UNAUTHORIZED) @ResponseBody - public ApiResponse handleAccessDeniedExceptionRest(AccessDeniedException exception) { + public ApiResponse handleAccessDeniedException(AccessDeniedException exception) { return UNAUTHORIZED_API_RESPONSE; } + @ExceptionHandler(CredentialsNotFoundException.class) + @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) + @ResponseBody + public ApiResponse handleCredentialsNotFoundException(CredentialsNotFoundException exception) { + return new ApiResponse(ApiStatus.ERROR, exception.getMessage()); + } + + @ExceptionHandler(UserNotFoundException.class) + @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) + @ResponseBody + public ApiResponse handleUserNotFoundException(UserNotFoundException exception) { + return new ApiResponse(ApiStatus.ERROR, exception.getMessage()); + } } \ No newline at end of file diff --git a/auth/src/main/java/edu/tamu/weaver/auth/exception/CredentialsNotFoundException.java b/auth/src/main/java/edu/tamu/weaver/auth/exception/CredentialsNotFoundException.java new file mode 100644 index 00000000..ba8a12fa --- /dev/null +++ b/auth/src/main/java/edu/tamu/weaver/auth/exception/CredentialsNotFoundException.java @@ -0,0 +1,11 @@ +package edu.tamu.weaver.auth.exception; + +public class CredentialsNotFoundException extends RuntimeException { + + private static final long serialVersionUID = -4128620872122571673L; + + public CredentialsNotFoundException(String message) { + super(message); + } + +} diff --git a/auth/src/main/java/edu/tamu/weaver/auth/exception/UserNotFoundException.java b/auth/src/main/java/edu/tamu/weaver/auth/exception/UserNotFoundException.java new file mode 100644 index 00000000..500d5a6f --- /dev/null +++ b/auth/src/main/java/edu/tamu/weaver/auth/exception/UserNotFoundException.java @@ -0,0 +1,11 @@ +package edu.tamu.weaver.auth.exception; + +public class UserNotFoundException extends RuntimeException { + + private static final long serialVersionUID = -7779314921709249299L; + + public UserNotFoundException(String message) { + super(message); + } + +} diff --git a/auth/src/main/java/edu/tamu/weaver/auth/resolver/WeaverCredentialsArgumentResolver.java b/auth/src/main/java/edu/tamu/weaver/auth/resolver/WeaverCredentialsArgumentResolver.java index b1d1bfdb..a8d4d8bb 100644 --- a/auth/src/main/java/edu/tamu/weaver/auth/resolver/WeaverCredentialsArgumentResolver.java +++ b/auth/src/main/java/edu/tamu/weaver/auth/resolver/WeaverCredentialsArgumentResolver.java @@ -9,24 +9,27 @@ import org.springframework.web.method.support.ModelAndViewContainer; import edu.tamu.weaver.auth.annotation.WeaverCredentials; +import edu.tamu.weaver.auth.exception.CredentialsNotFoundException; import edu.tamu.weaver.auth.model.Credentials; import edu.tamu.weaver.utility.AnnotationUtility; public final class WeaverCredentialsArgumentResolver implements HandlerMethodArgumentResolver { + @Override public boolean supportsParameter(MethodParameter parameter) { return AnnotationUtility.findMethodAnnotation(WeaverCredentials.class, parameter) != null; } + @Override public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { - return null; + throw new CredentialsNotFoundException("Authentication Object Not Found"); } if (!(authentication.getCredentials() instanceof Credentials)) { - return null; + throw new CredentialsNotFoundException("Authentication Object Missing Credentials"); } - return (Credentials) authentication.getCredentials(); + return authentication.getCredentials(); } } \ No newline at end of file diff --git a/auth/src/main/java/edu/tamu/weaver/auth/resolver/WeaverUserArgumentResolver.java b/auth/src/main/java/edu/tamu/weaver/auth/resolver/WeaverUserArgumentResolver.java index d51d34d7..f469ca50 100644 --- a/auth/src/main/java/edu/tamu/weaver/auth/resolver/WeaverUserArgumentResolver.java +++ b/auth/src/main/java/edu/tamu/weaver/auth/resolver/WeaverUserArgumentResolver.java @@ -11,6 +11,7 @@ import org.springframework.web.method.support.ModelAndViewContainer; import edu.tamu.weaver.auth.annotation.WeaverUser; +import edu.tamu.weaver.auth.exception.UserNotFoundException; import edu.tamu.weaver.auth.model.repo.AbstractWeaverUserRepo; import edu.tamu.weaver.user.model.AbstractWeaverUser; import edu.tamu.weaver.utility.AnnotationUtility; @@ -23,18 +24,20 @@ public WeaverUserArgumentResolver(R userRepo) { this.userRepo = userRepo; } + @Override public boolean supportsParameter(MethodParameter parameter) { return AnnotationUtility.findMethodAnnotation(WeaverUser.class, parameter) != null; } + @Override public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { - return null; + throw new UserNotFoundException("Authentication Object Not Found"); } Optional user = userRepo.findByUsername(authentication.getName()); if (!user.isPresent()) { - return null; + throw new UserNotFoundException("No User With Username " + authentication.getName()); } return user.get(); } diff --git a/cli/pom.xml b/cli/pom.xml deleted file mode 100644 index da04c44f..00000000 --- a/cli/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - - cli - - Weaver Command Line Interface - - Command Line Interface for Weaver - - - edu.tamu.weaver - webservice-parent - 2.0.0-RC4-SNAPSHOT - - - - - - - diff --git a/core/pom.xml b/core/pom.xml index 183855db..85e89bf9 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/data/pom.xml b/data/pom.xml index 27f02f07..3bbf66c1 100644 --- a/data/pom.xml +++ b/data/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT @@ -20,7 +20,7 @@ edu.tamu.weaver core - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/email/pom.xml b/email/pom.xml index 72d14afb..2f2b6951 100644 --- a/email/pom.xml +++ b/email/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/pom.xml b/pom.xml index a86a7773..659d5798 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT Weaver Webservice Parent @@ -26,7 +26,6 @@ email reporting - cli wro diff --git a/reporting/pom.xml b/reporting/pom.xml index 6cb392ef..de203bda 100644 --- a/reporting/pom.xml +++ b/reporting/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT @@ -20,13 +20,13 @@ edu.tamu.weaver core - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT edu.tamu.weaver email - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/token-provider/pom.xml b/token-provider/pom.xml index e03b3e9d..39d9c618 100644 --- a/token-provider/pom.xml +++ b/token-provider/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT @@ -25,13 +25,13 @@ edu.tamu.weaver token - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT edu.tamu.weaver core - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/token/pom.xml b/token/pom.xml index b5055bc6..c8f4305e 100644 --- a/token/pom.xml +++ b/token/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/user/pom.xml b/user/pom.xml index f6776473..a61f26ea 100644 --- a/user/pom.xml +++ b/user/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT @@ -21,13 +21,13 @@ edu.tamu.weaver data - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT edu.tamu.weaver validation - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/validation/pom.xml b/validation/pom.xml index c9951b66..c1e6da03 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -12,7 +12,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT @@ -21,7 +21,7 @@ edu.tamu.weaver data - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT diff --git a/wro/pom.xml b/wro/pom.xml index e16837d1..3135c2cb 100644 --- a/wro/pom.xml +++ b/wro/pom.xml @@ -1,4 +1,5 @@ - 4.0.0 @@ -12,7 +13,7 @@ edu.tamu.weaver webservice-parent - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT @@ -21,7 +22,7 @@ edu.tamu.weaver data - 2.0.0-RC4-SNAPSHOT + 2.0.0-RC5-SNAPSHOT @@ -34,6 +35,22 @@ ro.isdc.wro4j wro4j-extensions 1.8.0 + + + org.codehaus.gmaven.runtime + gmaven-runtime-1.7 + + + org.webjars + webjars-locator-core + + + + + + org.webjars + webjars-locator-core + 0.35 diff --git a/wro/src/main/java/edu/tamu/weaver/wro/config/WeaverWroConfiguration.java b/wro/src/main/java/edu/tamu/weaver/wro/config/WeaverWroConfiguration.java index 645ca55c..bd6b3556 100644 --- a/wro/src/main/java/edu/tamu/weaver/wro/config/WeaverWroConfiguration.java +++ b/wro/src/main/java/edu/tamu/weaver/wro/config/WeaverWroConfiguration.java @@ -71,9 +71,9 @@ public ThemeManager setThemeManagerServiceBean() { e.printStackTrace(); logger.error("Could not create ThemeManagerService Bean with class: "+themeManagerServiceClassName, e); } - } catch (ClassNotFoundException e1) { - logger.error("Could not find ThemeManagerService implementation class: "+themeManagerServiceClassName, e1); - } + } catch (ClassNotFoundException e) { + logger.warn("Could not find ThemeManagerService implementation class: " + themeManagerServiceClassName + "! Application must create theme manager bean!"); + } return null; } diff --git a/wro/src/main/java/edu/tamu/weaver/wro/resource/locator/SassClassPathUriLocator.java b/wro/src/main/java/edu/tamu/weaver/wro/resource/locator/SassClassPathUriLocator.java index e343a0e9..13fe9ab3 100644 --- a/wro/src/main/java/edu/tamu/weaver/wro/resource/locator/SassClassPathUriLocator.java +++ b/wro/src/main/java/edu/tamu/weaver/wro/resource/locator/SassClassPathUriLocator.java @@ -2,11 +2,13 @@ import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Optional; import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,7 +34,7 @@ public class SassClassPathUriLocator implements UriLocator { */ public static final String ALIAS = "sassClassPathUri"; - private ResourcePatternResolver resourcePatternResolver; + private ResourcePatternResolver resourcePatternResolver; public SassClassPathUriLocator(ResourcePatternResolver resourcePatternResolver) { this.resourcePatternResolver = resourcePatternResolver; @@ -89,7 +91,14 @@ private Optional getScssFile(String url) throws IOException { } if (resource.exists() && resource.isReadable()) { - file = Optional.of(resource.getFile()); + if (resource.getURI().getScheme().equals("jar")) { + File tempFile = File.createTempFile("wro", ".tmp"); + tempFile.deleteOnExit(); + IOUtils.copy(resource.getInputStream(), new FileOutputStream(tempFile)); + file = Optional.of(tempFile); + } else { + file = Optional.of(resource.getFile()); + } } return file;