diff --git a/giles-eco/pom.xml b/giles-eco/pom.xml
index 89ddd766..f6dfc87c 100755
--- a/giles-eco/pom.xml
+++ b/giles-eco/pom.xml
@@ -19,8 +19,8 @@
0.5
0.4.2
- 0.1
-
+ 0.2
+
geco-giles
TomcatServer
@@ -61,7 +61,7 @@
debug
-
+
com.mysql.jdbc.Driver
@@ -72,9 +72,22 @@
localhost:9092
+
+
+ localhost
+ 2181
+
+
+
+ 8080
+
+
+
+ true
+
@@ -465,6 +478,35 @@
${org.springframework-version}
+
+
+ javax.mail
+ mail
+ 1.5.0-b01
+
+
+ org.springframework
+ spring-context-support
+ ${org.springframework-version}
+
+
+ org.apache.velocity
+ velocity
+ 1.7
+
+
+ org.apache.velocity
+ velocity-tools
+ 2.0
+
+
+
+
+
+ org.apache.curator
+ curator-framework
+ 2.12.0
+
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/RestSecurityAspect.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/RestSecurityAspect.java
index b26ffc27..71aa9f86 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/RestSecurityAspect.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/RestSecurityAspect.java
@@ -29,6 +29,8 @@
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.AppTokenCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.AppTokenOnlyCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.DocumentAccessCheck;
@@ -77,6 +79,9 @@ public class RestSecurityAspect {
@Autowired
private List checkers;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
private Map tokenCheckers;
@@ -393,28 +398,28 @@ private ResponseEntity checkAuthorization(String token, String provider,
tokenHolder.checkResult = validationResult;
tokenHolder.tokenContents = validationResult.getPayload();
} catch (GeneralSecurityException e) {
- logger.error("Security issue with token.", e);
+ messageHandler.handleMessage("Security issue with token.", e, MessageType.ERROR);
Map msgs = new HashMap();
msgs.put("errorMsg", e.getLocalizedMessage());
msgs.put("provider", provider);
return generateResponse(msgs, HttpStatus.UNAUTHORIZED);
} catch (IOException e) {
- logger.error("Network issue.", e);
+ messageHandler.handleMessage("Network issue.", e, MessageType.ERROR);
Map msgs = new HashMap();
msgs.put("errorMsg", e.getLocalizedMessage());
msgs.put("provider", provider);
return generateResponse(msgs, HttpStatus.INTERNAL_SERVER_ERROR);
} catch (InvalidTokenException e) {
- logger.error("Token is invalid.", e);
+ messageHandler.handleMessage("Token is invalid.", e, MessageType.ERROR);
Map msgs = new HashMap();
msgs.put("errorMsg", e.getLocalizedMessage());
msgs.put("provider", provider);
return generateResponse(msgs, HttpStatus.UNAUTHORIZED);
} catch (ServerMisconfigurationException e) {
- logger.error("Server or apps are misconfigured.", e);
+ messageHandler.handleMessage("Server or apps are misconfigured.", e, MessageType.ERROR);
Map msgs = new HashMap();
msgs.put("errorMsg", e.getLocalizedMessage());
msgs.put("provider", provider);
@@ -469,7 +474,7 @@ private ResponseEntity extractUser(User user, IApiTokenContents tokenCon
}
private void fillUser(User filled, User toBeFilled) {
- toBeFilled.setAdmin(filled.getIsAdmin());
+ toBeFilled.setIsAdmin(filled.getIsAdmin());
toBeFilled.setEmail(filled.getEmail());
toBeFilled.setFirstname(filled.getFirstname());
toBeFilled.setLastname(filled.getLastname());
@@ -491,7 +496,7 @@ private ResponseEntity generateResponse(Map msgs, HttpSt
try {
mapper.writeValue(sw, root);
} catch (IOException e) {
- logger.error("Could not write json.", e);
+ messageHandler.handleMessage("Could not write json.", e, MessageType.ERROR);
return new ResponseEntity(
"{\"errorMsg\": \"Could not write json result.\", \"errorCode\": \"errorCode\": \"500\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/SecurityAspect.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/SecurityAspect.java
index a768b15e..32790baa 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/SecurityAspect.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/SecurityAspect.java
@@ -4,8 +4,6 @@
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -31,8 +29,6 @@
@Component
public class SecurityAspect {
- private Logger logger = LoggerFactory.getLogger(SecurityAspect.class);
-
@Autowired
private ITransactionalUploadService uploadService;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/tokens/impl/GitHubChecker.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/tokens/impl/GitHubChecker.java
index 81c9ead1..3f698be6 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/tokens/impl/GitHubChecker.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/tokens/impl/GitHubChecker.java
@@ -11,6 +11,8 @@
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.github.GitHubTemplateFactory;
import edu.asu.diging.gilesecosystem.web.aspects.access.openid.google.CheckerResult;
import edu.asu.diging.gilesecosystem.web.aspects.access.openid.google.ValidationResult;
@@ -28,7 +30,10 @@ public class GitHubChecker implements IChecker {
@Autowired
private GitHubTemplateFactory templateFactory;
-
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@Override
public String getId() {
return ID;
@@ -49,7 +54,7 @@ public CheckerResult validateToken(String token, String appId) throws GeneralSec
result.setPayload(contents);
result.setResult(ValidationResult.VALID);
} catch (RestClientException ex) {
- logger.warn("Could not authenticate user with GitHub.", ex);
+ messageHandler.handleMessage("Could not authenticate user with GitHub", ex, MessageType.WARNING);
// validation result already set
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/tokens/impl/GoogleChecker.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/tokens/impl/GoogleChecker.java
index 3c59bbc3..caaab0a2 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/tokens/impl/GoogleChecker.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/aspects/access/tokens/impl/GoogleChecker.java
@@ -6,7 +6,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.web.aspects.access.openid.google.Checker;
import edu.asu.diging.gilesecosystem.web.aspects.access.openid.google.CheckerResult;
@@ -19,9 +18,6 @@ public class GoogleChecker implements IChecker {
public final static String ID = "GOOGLE";
- @Autowired
- private IPropertiesManager propertiesManager;
-
@Autowired
private IRegisteredAppManager appsManager;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesTokenConfig.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesConfig.java
similarity index 93%
rename from giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesTokenConfig.java
rename to giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesConfig.java
index 082d8dc0..89f491b7 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesTokenConfig.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesConfig.java
@@ -15,6 +15,7 @@
import com.nimbusds.jose.util.Base64;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.septemberutil.service.impl.SystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
@@ -28,7 +29,7 @@
*
*/
@Configuration
-public class GilesTokenConfig {
+public class GilesConfig {
@Autowired
private IPropertiesManager propertyManager;
@@ -55,7 +56,7 @@ protected ClientHttpRequest createRequest(URI url, HttpMethod method) throws IOE
}
@Bean
- public SystemMessageHandler getMessageHandler() {
+ public ISystemMessageHandler getMessageHandler() {
return new SystemMessageHandler(propertyManager.getProperty(Properties.APPLICATION_ID));
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesConnectionSignUp.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesConnectionSignUp.java
index 01700d10..99d96d21 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesConnectionSignUp.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/GilesConnectionSignUp.java
@@ -1,17 +1,19 @@
package edu.asu.diging.gilesecosystem.web.config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionSignUp;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.users.IUserManager;
import edu.asu.diging.gilesecosystem.web.users.User;
public class GilesConnectionSignUp implements ConnectionSignUp {
- private final Logger logger = LoggerFactory.getLogger(getClass());
+ @Autowired
+ private ISystemMessageHandler messageHandler;
private IUserManager userManager;
private IUserHelper userHelper;
@@ -28,7 +30,7 @@ public String execute(Connection> connection) {
try {
userManager.addUser(user);
} catch (UnstorableObjectException e) {
- logger.error("Could not store user.", e);
+ messageHandler.handleMessage("Could not store user.", e, MessageType.ERROR);
return null;
}
return user.getUsername();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SecurityContext.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SecurityContext.java
index b2b84c10..82122220 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SecurityContext.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SecurityContext.java
@@ -27,7 +27,6 @@
import edu.asu.diging.gilesecosystem.web.users.IAdminUserDetailsService;
import edu.asu.diging.gilesecosystem.web.users.LocalUserDetailsService;
import edu.asu.diging.gilesecosystem.web.users.SimpleSocialUserDetailsService;
-import edu.asu.diging.gilesecosystem.web.users.impl.AdminUserDetailsService;
@Configuration
@EnableWebSecurity
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SimpleSignInAdapter.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SimpleSignInAdapter.java
index f0dbee30..2e5248b6 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SimpleSignInAdapter.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SimpleSignInAdapter.java
@@ -6,8 +6,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
@@ -17,6 +16,8 @@
import org.springframework.social.connect.web.SignInAdapter;
import org.springframework.web.context.request.NativeWebRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.users.GilesGrantedAuthority;
import edu.asu.diging.gilesecosystem.web.users.IUserManager;
@@ -24,7 +25,8 @@
public final class SimpleSignInAdapter implements SignInAdapter {
- private final Logger logger = LoggerFactory.getLogger(getClass());
+ @Autowired
+ private ISystemMessageHandler messageHandler;
private IUserManager userManager;
private IUserHelper userHelper;
@@ -48,7 +50,7 @@ public String signIn(String userId, Connection> connection,
try {
userManager.addUser(user);
} catch (UnstorableObjectException e) {
- logger.error("Could not add user.", e);
+ messageHandler.handleMessage("Could not add user.", e, MessageType.ERROR);
user = null;
}
} else {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SocialContext.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SocialContext.java
index 9e3c4682..c7755b2c 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SocialContext.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/SocialContext.java
@@ -16,12 +16,7 @@
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository;
import org.springframework.social.connect.web.ProviderSignInController;
-import org.springframework.social.github.api.GitHub;
-import org.springframework.social.github.connect.GitHubConnectionFactory;
-import org.springframework.social.google.api.Google;
import org.springframework.social.google.connect.GoogleConnectionFactory;
-import org.springframework.social.mitreidconnect.api.MitreidConnect;
-import org.springframework.social.mitreidconnect.connect.MitreidConnectConnectionFactory;
import org.springframework.social.security.AuthenticationNameUserIdSource;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableGithubConnectionFactory.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableGithubConnectionFactory.java
index 8984751b..296ec269 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableGithubConnectionFactory.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableGithubConnectionFactory.java
@@ -1,8 +1,6 @@
package edu.asu.diging.gilesecosystem.web.config.social;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.social.ServiceProvider;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.Connection;
@@ -20,8 +18,6 @@
public class AdjustableGithubConnectionFactory extends OAuth2ConnectionFactory implements IAdjustableConnectionFactory {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
private GitHubConnectionFactory delegate;
public AdjustableGithubConnectionFactory(String providerId,
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableGoogleConnectionFactory.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableGoogleConnectionFactory.java
index 5cb7cb3e..983da028 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableGoogleConnectionFactory.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableGoogleConnectionFactory.java
@@ -1,14 +1,11 @@
package edu.asu.diging.gilesecosystem.web.config.social;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.social.ServiceProvider;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionData;
import org.springframework.social.connect.support.OAuth2ConnectionFactory;
-import org.springframework.social.github.api.GitHub;
import org.springframework.social.google.api.Google;
import org.springframework.social.google.connect.GoogleAdapter;
import org.springframework.social.google.connect.GoogleConnectionFactory;
@@ -21,8 +18,6 @@
public class AdjustableGoogleConnectionFactory extends OAuth2ConnectionFactory implements IAdjustableConnectionFactory {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
private GoogleConnectionFactory delegate;
public AdjustableGoogleConnectionFactory(String providerId,
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableMitreidConnectionFactory.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableMitreidConnectionFactory.java
index aafe2345..c01451e5 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableMitreidConnectionFactory.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/config/social/AdjustableMitreidConnectionFactory.java
@@ -1,8 +1,6 @@
package edu.asu.diging.gilesecosystem.web.config.social;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.social.ServiceProvider;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.Connection;
@@ -21,8 +19,6 @@
public class AdjustableMitreidConnectionFactory extends OAuth2ConnectionFactory implements IAdjustableConnectionFactory {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
private MitreidConnectConnectionFactory delegate;
private String providerUrl;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/ChangeAccessController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/ChangeAccessController.java
index 5ccff6e7..010c34f3 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/ChangeAccessController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/ChangeAccessController.java
@@ -1,7 +1,5 @@
package edu.asu.diging.gilesecosystem.web.controllers;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
@@ -10,6 +8,8 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.AccountCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.DocumentIdAccessCheck;
@@ -21,14 +21,15 @@
@Controller
public class ChangeAccessController {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private IFilesManager filesManager;
@Autowired
private ITransactionalDocumentService documentService;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@AccountCheck
@DocumentIdAccessCheck("documentId")
@RequestMapping(value = "/documents/{documentId}/access/change", method = RequestMethod.POST)
@@ -74,7 +75,7 @@ public String changeAccess(@PathVariable("documentId") String documentId,
} catch (UnstorableObjectException e) {
// this should not happen, since it's an existing object
- logger.error("Could not store document.", e);
+ messageHandler.handleMessage("Could not store document.", e, MessageType.ERROR);
redirectAttrs.addAttribute("show_alert", true);
redirectAttrs.addAttribute("alert_type", "danger");
redirectAttrs.addAttribute("alert_msg",
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/FileContentController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/FileContentController.java
index 6315f6f9..bca78f11 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/FileContentController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/FileContentController.java
@@ -6,8 +6,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -15,6 +13,8 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.AccountCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.FileAccessCheck;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
@@ -24,14 +24,15 @@
@Controller
public class FileContentController {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private IFilesManager filesManager;
@Autowired
private ITransactionalFileService fileService;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@AccountCheck
@FileAccessCheck
@RequestMapping(value = "/files/{fileId}/content")
@@ -53,7 +54,7 @@ public ResponseEntity getFile(
response.getOutputStream().write(content);
response.getOutputStream().close();
} catch (IOException e) {
- logger.error("Could not write to output stream.", e);
+ messageHandler.handleMessage("Could not write to output stream.", e, MessageType.ERROR);
return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/UploadController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/UploadController.java
index a9fbca6e..a4c2d4d6 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/UploadController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/UploadController.java
@@ -4,8 +4,6 @@
import java.util.List;
import java.util.Locale;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -25,24 +23,13 @@
import edu.asu.diging.gilesecosystem.web.controllers.util.StatusBadgeHelper;
import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
import edu.asu.diging.gilesecosystem.web.domain.DocumentType;
-import edu.asu.diging.gilesecosystem.web.files.IFilesManager;
import edu.asu.diging.gilesecosystem.web.files.impl.StorageStatus;
import edu.asu.diging.gilesecosystem.web.service.upload.IUploadService;
import edu.asu.diging.gilesecosystem.web.users.User;
-import edu.asu.diging.gilesecosystem.web.util.FileUploadHelper;
@Controller
public class UploadController {
- private static Logger logger = LoggerFactory
- .getLogger(UploadController.class);
-
- @Autowired
- private IFilesManager filesManager;
-
- @Autowired
- private FileUploadHelper uploadHelper;
-
@Autowired
private StatusBadgeHelper statusHelper;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/ViewImageController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/ViewImageController.java
index 91d823e0..e043e5ca 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/ViewImageController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/ViewImageController.java
@@ -9,8 +9,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -19,6 +17,8 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.AccountCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.FileAccessCheck;
import edu.asu.diging.gilesecosystem.web.controllers.pages.FilePageBean;
@@ -33,8 +33,6 @@
@Controller
public class ViewImageController {
- private Logger logger = LoggerFactory.getLogger(ViewImageController.class);
-
@Autowired
private DigilibConnector digilibConnector;
@@ -43,6 +41,9 @@ public class ViewImageController {
@Autowired
private IMetadataUrlService metadataService;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
@AccountCheck
@FileAccessCheck
@@ -72,7 +73,7 @@ public ResponseEntity viewImage(
try {
parameterBuffer.append(URLEncoder.encode(file.getFilepath(), "UTF-8"));
} catch (UnsupportedEncodingException e1) {
- logger.error("Could not encode path.", e1);
+ messageHandler.handleMessage("Could not encode path.", e1, MessageType.ERROR);
parameterBuffer.append(file.getFilepath());
}
@@ -80,11 +81,11 @@ public ResponseEntity viewImage(
digilibConnector.getDigilibImage(parameterBuffer.toString(),
response);
} catch (MalformedURLException e) {
- logger.error(e.getMessage(), e);
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(e.getMessage(),
HttpStatus.INTERNAL_SERVER_ERROR);
} catch (IOException e) {
- logger.error(e.getMessage(), e);
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(e.getMessage(),
HttpStatus.INTERNAL_SERVER_ERROR);
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/AddRegisteredAppController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/AddRegisteredAppController.java
index bd899ab6..60bf88c9 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/AddRegisteredAppController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/AddRegisteredAppController.java
@@ -1,7 +1,5 @@
package edu.asu.diging.gilesecosystem.web.controllers.admin;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -14,6 +12,8 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.web.apps.impl.RegisteredApp;
import edu.asu.diging.gilesecosystem.web.exceptions.TokenGenerationErrorException;
@@ -25,13 +25,14 @@
@Controller
public class AddRegisteredAppController {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private IRegisteredAppManager appManager;
@Autowired
private IIdentityProviderRegistry providerRegistry;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
@InitBinder("app")
public void init(WebDataBinder binder) {
@@ -61,7 +62,7 @@ public String registerApp(@Validated @ModelAttribute("app") RegisteredApp app, B
try {
token = appManager.createToken(newApp);
} catch (TokenGenerationErrorException e) {
- logger.error("Token generation failed.", e);
+ messageHandler.handleMessage("Token generation failed.", e, MessageType.ERROR);
redirectAttrs.addFlashAttribute("show_alert", true);
redirectAttrs.addFlashAttribute("alert_type", "danger");
redirectAttrs.addFlashAttribute("alert_msg", "You app has been registered, but token generation failed.");
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/AdministratorPasswordController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/AdministratorPasswordController.java
index 60f11ef9..3a0684fc 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/AdministratorPasswordController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/AdministratorPasswordController.java
@@ -3,8 +3,6 @@
import java.security.Principal;
import java.util.Locale;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
@@ -18,6 +16,8 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.controllers.admin.pages.AdminUser;
import edu.asu.diging.gilesecosystem.web.exceptions.BadPasswordException;
import edu.asu.diging.gilesecosystem.web.exceptions.UnauthorizedException;
@@ -27,8 +27,6 @@
@Controller
public class AdministratorPasswordController {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private MessageSource messageSource;
@@ -38,6 +36,9 @@ public class AdministratorPasswordController {
@Autowired
private IAdminUserManager adminManager;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@InitBinder
public void init(WebDataBinder binder) {
binder.addValidators(validator);
@@ -75,7 +76,7 @@ public String changePassword(@Validated @ModelAttribute("adminUser") AdminUser a
success = adminManager.updatePassword(adminUser.getUsername(), adminUser.getOldPassword(), adminUser.getNewPassword());
} catch (BadPasswordException | UnauthorizedException e) {
// this should never happen because it should be caught by the validator
- logger.error("Could not update password.", e);
+ messageHandler.handleMessage("Could not update password.", e, MessageType.ERROR);
}
if (success) {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/EditPropertiesController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/EditPropertiesController.java
index 7bbed64f..1967c73a 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/EditPropertiesController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/EditPropertiesController.java
@@ -21,6 +21,8 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.PropertiesStorageException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.controllers.admin.pages.SystemConfigPage;
@@ -32,6 +34,9 @@ public class EditPropertiesController {
@Autowired
private IPropertiesManager propertyManager;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder, WebDataBinder validateBinder) {
@@ -93,6 +98,7 @@ public String storeSystemConfig(@Validated @ModelAttribute SystemConfigPage syst
try {
propertyManager.updateProperties(propertiesMap);
} catch (PropertiesStorageException e) {
+ messageHandler.handleMessage("System Configuration could not be saved.", e, MessageType.ERROR);
model.addAttribute("show_alert", true);
model.addAttribute("alert_type", "danger");
model.addAttribute("alert_msg", "An unexpected error occurred. System Configuration could not be saved.");
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/SigningSecretController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/SigningSecretController.java
index 0d6efa59..c426076e 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/SigningSecretController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/SigningSecretController.java
@@ -3,14 +3,14 @@
import java.util.HashMap;
import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.PropertiesStorageException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
@@ -19,15 +19,15 @@
@Controller
public class SigningSecretController {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
-
@Autowired
private ISigningSecretGenerator secretGenerator;
@Autowired
private IPropertiesManager propertiesManager;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@RequestMapping(value="/admin/system/auth")
public String showPage(Model model) {
@@ -47,7 +47,7 @@ public String generateSecrets(Model model) {
try {
propertiesManager.updateProperties(props);
} catch (PropertiesStorageException e) {
- logger.error("Properties could not be stored.", e);
+ messageHandler.handleMessage("Properties could not be stored.", e, MessageType.ERROR);
}
return "admin/system/auth/done";
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/SocialSigninUpdateController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/SocialSigninUpdateController.java
index a122ac94..6faee11f 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/SocialSigninUpdateController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/controllers/admin/SocialSigninUpdateController.java
@@ -3,8 +3,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -12,6 +10,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.PropertiesStorageException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.config.IReloadService;
@@ -22,14 +22,15 @@
@Controller
public class SocialSigninUpdateController {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private IReloadService connFactoryService;
@Autowired
private IPropertiesManager propertiesManager;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@RequestMapping(value="/admin/system/social")
public String showUpdatePage(Model model) {
@@ -76,13 +77,13 @@ public String updateGithubConfig(@ModelAttribute SignInProviderConfig config, Mo
try {
propertiesManager.updateProperties(githubConfig);
} catch (PropertiesStorageException e) {
- logger.error("Could not store properties.", e);
+ messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR);
}
try {
connFactoryService.updateFactory(IReloadService.GITHUB, config.getClientId(), config.getSecret());
} catch (FactoryDoesNotExistException e) {
- logger.error("Could not update factory.", e);
+ messageHandler.handleMessage("Could not update factory.", e, MessageType.ERROR);
}
return "redirect:/admin/system/social";
@@ -100,13 +101,13 @@ public String updateGoogleConfig(@ModelAttribute SignInProviderConfig config, Mo
try {
propertiesManager.updateProperties(googleConfig);
} catch (PropertiesStorageException e) {
- logger.error("Could not store properties.", e);
+ messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR);
}
try {
connFactoryService.updateFactory(IReloadService.GOOGLE, config.getClientId(), config.getSecret());
} catch (FactoryDoesNotExistException e) {
- logger.error("Could not update factory.", e);
+ messageHandler.handleMessage("Could not update factory.", e, MessageType.ERROR);
}
return "redirect:/admin/system/social";
@@ -125,14 +126,14 @@ public String updateMitreidConfig(@ModelAttribute SignInProviderConfig config, M
try {
propertiesManager.updateProperties(mitreidConfig);
} catch (PropertiesStorageException e) {
- logger.error("Could not store properties.", e);
+ messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR);
}
try {
connFactoryService.updateFactory(IReloadService.MITREID, config.getClientId(), config.getSecret(), config.getUrl());
} catch (FactoryDoesNotExistException e) {
- logger.error("Could not update factory.", e);
+ messageHandler.handleMessage("Could not update factory.", e, MessageType.ERROR);
}
return "redirect:/admin/system/social";
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/DocumentAccess.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/DocumentAccess.java
index 689f3806..5aa9bed6 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/DocumentAccess.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/DocumentAccess.java
@@ -1,5 +1,13 @@
package edu.asu.diging.gilesecosystem.web.core;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.DocumentAccess} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
public enum DocumentAccess {
PUBLIC, PRIVATE, AUTHENTICATED
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/DocumentType.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/DocumentType.java
index 4408ef9c..d6ad8bce 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/DocumentType.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/DocumentType.java
@@ -3,9 +3,14 @@
/**
* Enum to specify if a document has one or several pages.
*
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.DocumentType} instead. This
+ * class is only kept for migration purposes.
+ *
* @author jdamerow
*
*/
+@Deprecated
public enum DocumentType {
SINGLE_PAGE, MULTI_PAGE
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IDocument.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IDocument.java
index efd1f659..61676036 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IDocument.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IDocument.java
@@ -5,6 +5,14 @@
import edu.asu.diging.gilesecosystem.requests.IRequest;
import edu.asu.diging.gilesecosystem.util.store.IStorableObject;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.IDocument} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
public interface IDocument extends IStorableObject {
public abstract String getId();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IFile.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IFile.java
index bddd7ad0..ee89dad0 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IFile.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IFile.java
@@ -2,6 +2,14 @@
import edu.asu.diging.gilesecosystem.util.store.IStorableObject;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.IFile} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
public interface IFile extends IStorableObject {
public abstract String getUploadId();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IPage.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IPage.java
index a716df0a..a0a62ae6 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IPage.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IPage.java
@@ -1,6 +1,13 @@
package edu.asu.diging.gilesecosystem.web.core;
-
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.IPage} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
public interface IPage {
public abstract int getPageNr();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IProcessingRequest.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IProcessingRequest.java
index 1d6ebf1d..81ec8abd 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IProcessingRequest.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IProcessingRequest.java
@@ -4,6 +4,14 @@
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
import edu.asu.diging.gilesecosystem.util.store.IStorableObject;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.IProcessingRequest} instead. This
+ * interface is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
public interface IProcessingRequest extends IStorableObject {
public abstract String getId();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/ITask.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/ITask.java
index 09edc410..6a16cb68 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/ITask.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/ITask.java
@@ -2,6 +2,14 @@
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.ITask} instead. This
+ * interface is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
public interface ITask {
public abstract String getTaskHandlerId();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IUpload.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IUpload.java
index 360ac788..958f673a 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IUpload.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/IUpload.java
@@ -2,7 +2,14 @@
import edu.asu.diging.gilesecosystem.util.store.IStorableObject;
-
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.IUpload} instead. This
+ * interface is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
public interface IUpload extends IStorableObject {
public abstract String getId();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/ProcessingStatus.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/ProcessingStatus.java
index 42b859c3..d6604225 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/ProcessingStatus.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/ProcessingStatus.java
@@ -12,8 +12,13 @@
* COMPLETE: process complete
*
* @author jdamerow
+ *
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.ProcessingStatus} instead. This
+ * enum is only kept for migration purposes.
*
*/
+@Deprecated
public enum ProcessingStatus {
UNPROCESSED,
AWAITING_STORAGE,
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Document.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Document.java
index dcd4adc7..abd6f291 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Document.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Document.java
@@ -19,6 +19,14 @@
import edu.asu.diging.gilesecosystem.web.core.IPage;
import edu.asu.diging.gilesecosystem.web.core.ITask;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.impl.Document} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
@Entity
public class Document implements IDocument {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/File.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/File.java
index cff4c6a7..bc8a6689 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/File.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/File.java
@@ -8,6 +8,14 @@
import edu.asu.diging.gilesecosystem.web.core.IFile;
import edu.asu.diging.gilesecosystem.web.core.ProcessingStatus;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.impl.File} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
@Entity
public class File implements IFile {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Page.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Page.java
index c526e1aa..06a36404 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Page.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Page.java
@@ -4,6 +4,14 @@
import edu.asu.diging.gilesecosystem.web.core.IPage;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.impl.Page} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
@Embeddable
public class Page implements IPage {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/ProcessingRequest.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/ProcessingRequest.java
index 7f7a5c16..ce2e7032 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/ProcessingRequest.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/ProcessingRequest.java
@@ -13,9 +13,14 @@
/**
* Storage class for request objects.
*
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.impl.ProcessingRequest} instead. This
+ * class is only kept for migration purposes.
+ *
* @author jdamerow
*
*/
+@Deprecated
@Entity
public class ProcessingRequest implements IProcessingRequest {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Task.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Task.java
index a4c565e4..7608935e 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Task.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Task.java
@@ -5,6 +5,14 @@
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
import edu.asu.diging.gilesecosystem.web.core.ITask;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.impl.Task} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
@Embeddable
public class Task implements ITask {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Upload.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Upload.java
index c6c887f3..abe2fddb 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Upload.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/core/impl/Upload.java
@@ -6,6 +6,14 @@
import edu.asu.diging.gilesecosystem.web.core.IUpload;
+/**
+ * @deprecated
+ * Use {@link edu.asu.diging.gilesecosystem.web.domain.impl.Upload} instead. This
+ * class is only kept for migration purposes.
+ * @author jdamerow
+ *
+ */
+@Deprecated
@Entity
public class Upload implements IUpload {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/domain/impl/Document.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/domain/impl/Document.java
index 2d4d46d4..cbd8793f 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/domain/impl/Document.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/domain/impl/Document.java
@@ -8,6 +8,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
+import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@@ -39,10 +40,19 @@ public class Document implements IDocument {
private transient List files;
private DocumentType documentType;
private int pageCount;
- @ElementCollection @LazyCollection(LazyCollectionOption.FALSE) private List textFileIds;
- @OneToMany(cascade=CascadeType.ALL, targetEntity=Page.class, mappedBy="document") @LazyCollection(LazyCollectionOption.FALSE) private List pages;
-
- @OneToMany(cascade=CascadeType.ALL, targetEntity=Task.class) @LazyCollection(LazyCollectionOption.FALSE) private List tasks;
+
+ @ElementCollection
+ @LazyCollection(LazyCollectionOption.FALSE)
+ private List textFileIds;
+
+ @OneToMany(cascade=CascadeType.ALL, targetEntity=Page.class, mappedBy="document")
+ @LazyCollection(LazyCollectionOption.FALSE)
+ private List pages;
+
+ @OneToMany(cascade=CascadeType.ALL, targetEntity=Task.class)
+ @LazyCollection(LazyCollectionOption.FALSE)
+ @JoinTable(name="Document_Task")
+ private List tasks;
/*
* (non-Javadoc)
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/IEmailNotificationManager.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/IEmailNotificationManager.java
new file mode 100644
index 00000000..ea363aa8
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/IEmailNotificationManager.java
@@ -0,0 +1,24 @@
+package edu.asu.diging.gilesecosystem.web.email;
+
+import edu.asu.diging.gilesecosystem.web.exceptions.GilesNotificationException;
+
+/**
+ * The purpose of this interface is to manage all the outgoing mails in the
+ * system.
+ *
+ * @author snilapwa
+ */
+public interface IEmailNotificationManager {
+
+ /**
+ * Send new account creation email notification to admin
+ *
+ * @param name name of new user
+ * @param username username of new user
+ * @param adminName name of email recipient admin
+ * @param adminEmail email id of recipient admin
+ * @throws GilesNotificationException
+ */
+ void sendAccountCreatedEmail(String name, String username, String adminName, String adminEmail)
+ throws GilesNotificationException;
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/IEmailNotificationSender.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/IEmailNotificationSender.java
new file mode 100644
index 00000000..b10d7d8b
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/IEmailNotificationSender.java
@@ -0,0 +1,10 @@
+package edu.asu.diging.gilesecosystem.web.email;
+
+/**
+ * The purpose of this interface is to send email notifications.
+ *
+ * @author snilapwa
+ */
+public interface IEmailNotificationSender {
+ public void sendNotificationEmail(String emailaddress, String subject, String msgText);
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/impl/EmailNotificationManager.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/impl/EmailNotificationManager.java
new file mode 100644
index 00000000..76d135d4
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/impl/EmailNotificationManager.java
@@ -0,0 +1,56 @@
+package edu.asu.diging.gilesecosystem.web.email.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
+import org.springframework.stereotype.Service;
+
+import edu.asu.diging.gilesecosystem.web.email.IEmailNotificationManager;
+import edu.asu.diging.gilesecosystem.web.exceptions.GilesNotificationException;
+import edu.asu.diging.gilesecosystem.web.velocity.IVelocityBuilder;
+
+@Service
+public class EmailNotificationManager implements IEmailNotificationManager {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ private EmailNotificationSender emailSender;
+
+ @Autowired
+ private IVelocityBuilder velocityBuilder;
+
+ @Autowired
+ private MessageSource emailMessages;
+
+ @Override
+ public void sendAccountCreatedEmail(String name, String username, String adminName, String adminEmail)
+ throws GilesNotificationException {
+ Map contextProperties = new HashMap();
+
+ contextProperties.put("createdUser", name);
+ contextProperties.put("createdUsername", username);
+ contextProperties.put("admin", adminName);
+
+ try {
+ String msg = velocityBuilder.getRenderedTemplate("velocitytemplates/email/newAccount.vm",
+ contextProperties);
+ emailSender.sendNotificationEmail(adminEmail, emailMessages.getMessage("email.account_created.subject", new String[]{}, null),
+ msg);
+ } catch (ResourceNotFoundException e) {
+ throw new GilesNotificationException(e);
+ } catch (ParseErrorException e) {
+ throw new GilesNotificationException(e);
+ } catch (Exception e) {
+ //getTemplate method call under getRenderedTemplate can throw exception
+ throw new GilesNotificationException(e);
+ }
+ }
+
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/impl/EmailNotificationSender.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/impl/EmailNotificationSender.java
new file mode 100644
index 00000000..94f04759
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/email/impl/EmailNotificationSender.java
@@ -0,0 +1,60 @@
+package edu.asu.diging.gilesecosystem.web.email.impl;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSource;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessageHelper;
+import org.springframework.stereotype.Service;
+
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
+import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
+import edu.asu.diging.gilesecosystem.web.email.IEmailNotificationSender;
+import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
+
+@Service
+public class EmailNotificationSender implements IEmailNotificationSender {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ private JavaMailSender mailSender;
+
+ @Autowired
+ private IPropertiesManager propertyManager;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
+ @Autowired
+ private MessageSource emailMessages;
+
+ public void sendNotificationEmail(String emailaddress, String subject, String msgText) {
+ boolean enabled = (propertyManager.getProperty(Properties.EMAIL_ENABLED)).equals("true");
+ String fromAddress= propertyManager.getProperty(Properties.EMAIL_FROM);
+ if (enabled) {
+ try {
+ MimeMessage message = mailSender.createMimeMessage();
+ MimeMessageHelper helper = new MimeMessageHelper(message, true);
+ helper.setTo(new InternetAddress(emailaddress));
+ helper.setSubject(subject);
+ helper.setFrom(new InternetAddress(fromAddress));
+
+ // Adding tail to the message text
+ msgText += emailMessages.getMessage("email.tail", new String[]{}, null);
+
+ helper.setText(msgText);
+ mailSender.send(message);
+ logger.debug("Send email to " + emailaddress + " with subject \"" + subject + "\"");
+ } catch (MessagingException ex) {
+ messageHandler.handleMessage("Notification email could not be sent.", ex, MessageType.ERROR);
+ }
+ }
+ }
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/exceptions/GilesNotificationException.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/exceptions/GilesNotificationException.java
new file mode 100644
index 00000000..b13759f4
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/exceptions/GilesNotificationException.java
@@ -0,0 +1,32 @@
+package edu.asu.diging.gilesecosystem.web.exceptions;
+
+/**
+ * Exception class for notification exceptions
+ *
+ * @author snilapwa
+ */
+public class GilesNotificationException extends Exception {
+
+ private static final long serialVersionUID = 5203233497728362534L;
+
+ public GilesNotificationException() {
+ super();
+ }
+
+ public GilesNotificationException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ public GilesNotificationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public GilesNotificationException(String message) {
+ super(message);
+ }
+
+ public GilesNotificationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/exceptions/NoNepomukFoundException.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/exceptions/NoNepomukFoundException.java
new file mode 100644
index 00000000..74a9f1da
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/exceptions/NoNepomukFoundException.java
@@ -0,0 +1,35 @@
+package edu.asu.diging.gilesecosystem.web.exceptions;
+
+public class NoNepomukFoundException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5020481321817376225L;
+
+ public NoNepomukFoundException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public NoNepomukFoundException(String message, Throwable cause,
+ boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ // TODO Auto-generated constructor stub
+ }
+
+ public NoNepomukFoundException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public NoNepomukFoundException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public NoNepomukFoundException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/IProcessingRequestsDatabaseClient.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/IProcessingRequestsDatabaseClient.java
index ea8a8e9a..fe2142e3 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/IProcessingRequestsDatabaseClient.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/IProcessingRequestsDatabaseClient.java
@@ -4,7 +4,6 @@
import edu.asu.diging.gilesecosystem.util.store.IDatabaseClient;
import edu.asu.diging.gilesecosystem.web.domain.IProcessingRequest;
-import edu.asu.diging.gilesecosystem.web.domain.impl.ProcessingRequest;
public interface IProcessingRequestsDatabaseClient extends IDatabaseClient {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/FilesDatabaseClient.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/FilesDatabaseClient.java
index 3213200f..2dcc055e 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/FilesDatabaseClient.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/FilesDatabaseClient.java
@@ -6,7 +6,6 @@
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.util.store.objectdb.DatabaseClient;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/FilesManager.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/FilesManager.java
index 74c31489..e0d7127e 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/FilesManager.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/FilesManager.java
@@ -7,13 +7,13 @@
import java.util.List;
import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
import edu.asu.diging.gilesecosystem.web.domain.DocumentType;
@@ -37,8 +37,6 @@
@Service
public class FilesManager implements IFilesManager {
- private Logger logger = LoggerFactory.getLogger(FilesManager.class);
-
@Autowired
private ITransactionalFileService fileService;
@@ -54,6 +52,8 @@ public class FilesManager implements IFilesManager {
@Autowired
private IProcessingCoordinator processCoordinator;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
/*
* (non-Javadoc)
*
@@ -113,10 +113,10 @@ public List addFiles(Map files,
RequestStatus requestStatus = processCoordinator.processFile(file, info);
statuses.add(new StorageStatus(document, file, null, requestStatus));
} catch (GilesProcessingException e) {
- logger.error("Could not store uploaded files.", e);
+ messageHandler.handleMessage("Could not store uploaded files.", e, MessageType.ERROR);
statuses.add(new StorageStatus(document, file, e, RequestStatus.FAILED));
} catch (UnstorableObjectException e) {
- logger.error("Object is not storable. Please review your code.", e);
+ messageHandler.handleMessage("Object is not storable. Please review your code.", e, MessageType.ERROR);
statuses.add(new StorageStatus(document, file, new GilesProcessingException(e), RequestStatus.FAILED));
}
}
@@ -129,7 +129,7 @@ public List addFiles(Map files,
} catch (UnstorableObjectException e) {
// let's silently fail because this should never happen
// we set the id
- logger.error("Could not store upload.", e);
+ messageHandler.handleMessage("Could not store upload.", e, MessageType.ERROR);
}
}
@@ -233,7 +233,7 @@ private boolean changeFileAccess(IFile file, DocumentAccess docAccess) {
try {
fileService.saveFile(file);
} catch (UnstorableObjectException e) {
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
return false;
}
return true;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/ProcessingRequestsDatabaseClient.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/ProcessingRequestsDatabaseClient.java
index 42119ca4..840d77f5 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/ProcessingRequestsDatabaseClient.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/ProcessingRequestsDatabaseClient.java
@@ -7,11 +7,12 @@
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.util.store.objectdb.DatabaseClient;
import edu.asu.diging.gilesecosystem.web.domain.IProcessingRequest;
@@ -22,11 +23,12 @@
@Component
public class ProcessingRequestsDatabaseClient extends DatabaseClient implements IProcessingRequestsDatabaseClient {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@PersistenceContext(unitName="entityManagerFactory")
private EntityManager em;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@Override
public List getRequestByDocumentId(String docId) {
return searchByProperty("documentId", docId, ProcessingRequest.class);
@@ -44,7 +46,7 @@ public void saveNewRequest(IProcessingRequest request) {
store(request);
} catch (UnstorableObjectException e) {
// should never happen
- logger.error("Could not store element.", e);
+ messageHandler.handleMessage("Could not store element.", e, MessageType.ERROR);
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/UploadDatabaseClient.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/UploadDatabaseClient.java
index c10cb25e..2042f14a 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/UploadDatabaseClient.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/files/impl/UploadDatabaseClient.java
@@ -7,8 +7,6 @@
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -23,8 +21,6 @@
public class UploadDatabaseClient extends DatabaseClient implements
IUploadDatabaseClient {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@PersistenceContext(unitName="entityManagerFactory")
private EntityManager em;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/kafka/KafkaProcessingListener.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/kafka/KafkaProcessingListener.java
index a5a9f9b5..eb72f87b 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/kafka/KafkaProcessingListener.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/kafka/KafkaProcessingListener.java
@@ -8,8 +8,6 @@
import javax.annotation.PostConstruct;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.PropertySource;
@@ -21,17 +19,20 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.asu.diging.gilesecosystem.requests.IRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.service.processing.RequestProcessor;
@PropertySource("classpath:/config.properties")
public class KafkaProcessingListener {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private ApplicationContext ctx;
private Map> requestProcessors;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
@PostConstruct
public void init() {
@@ -61,7 +62,7 @@ public void receiveMessage(String message, @Header(KafkaHeaders.RECEIVED_TOPIC)
try {
request = mapper.readValue(message, processor.getRequestClass());
} catch (IOException e) {
- logger.error("Could not unmarshall request.", e);
+ messageHandler.handleMessage("Could not unmarshall request.", e, MessageType.ERROR);
// FIXME: handle this case
return;
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/nepomuk/INepomukUrlService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/nepomuk/INepomukUrlService.java
new file mode 100644
index 00000000..fd00c651
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/nepomuk/INepomukUrlService.java
@@ -0,0 +1,18 @@
+package edu.asu.diging.gilesecosystem.web.nepomuk;
+
+import edu.asu.diging.gilesecosystem.web.domain.IFile;
+import edu.asu.diging.gilesecosystem.web.zookeeper.INepomukServiceDiscoverer;
+
+public interface INepomukUrlService {
+
+ /**
+ * Returns a download path for a file. This method requests a Nepomuk
+ * URL from the {@link INepomukServiceDiscoverer} and then builds a download path
+ * for the provided file.
+ *
+ * @param file The file for which a download path is requested.
+ * @return Path to download file from Nepomuk.
+ */
+ String getFileDownloadPath(IFile file);
+
+}
\ No newline at end of file
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/nepomuk/impl/NepomukUrlService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/nepomuk/impl/NepomukUrlService.java
new file mode 100644
index 00000000..80249c3a
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/nepomuk/impl/NepomukUrlService.java
@@ -0,0 +1,48 @@
+package edu.asu.diging.gilesecosystem.web.nepomuk.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
+import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
+import edu.asu.diging.gilesecosystem.web.domain.IFile;
+import edu.asu.diging.gilesecosystem.web.exceptions.NoNepomukFoundException;
+import edu.asu.diging.gilesecosystem.web.nepomuk.INepomukUrlService;
+import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
+import edu.asu.diging.gilesecosystem.web.zookeeper.INepomukServiceDiscoverer;
+
+/**
+ * Helper class for Nepomuk URL.
+ *
+ * @author jdamerow
+ *
+ */
+@Service
+public class NepomukUrlService implements INepomukUrlService {
+
+ @Autowired
+ protected INepomukServiceDiscoverer nepomukDiscoverer;
+
+ @Autowired
+ protected IPropertiesManager propertyManager;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
+ /* (non-Javadoc)
+ * @see edu.asu.diging.gilesecosystem.web.nepomuk.impl.INepomukUrlService#getFileDownloadPath(edu.asu.diging.gilesecosystem.web.domain.IFile)
+ */
+ @Override
+ public String getFileDownloadPath(IFile file) {
+ String nepomukUrl;
+ try {
+ nepomukUrl = nepomukDiscoverer.getRandomNepomukInstance();
+ } catch (NoNepomukFoundException e) {
+ messageHandler.handleMessage("Could not download file. Nepomuk could not be reached.", e, MessageType.ERROR);
+ return null;
+ }
+
+ return nepomukUrl + propertyManager.getProperty(Properties.NEPOMUK_FILES_ENDPOINT).replace("{0}", file.getStorageId());
+ }
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/ChangeDocumentAccessController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/ChangeDocumentAccessController.java
index ae532efd..90ca32c9 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/ChangeDocumentAccessController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/ChangeDocumentAccessController.java
@@ -13,6 +13,8 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.TokenCheck;
import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
@@ -34,6 +36,9 @@ public class ChangeDocumentAccessController {
@Autowired
private ITransactionalDocumentService documentService;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@TokenCheck
@RequestMapping(value = GET_DOCUMENT_PATH
+ "/access/change", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@@ -55,7 +60,7 @@ public ResponseEntity changeDocumentAccess(@RequestParam(defaultValue =
return new ResponseEntity("{\"error\": \"Incorrect access type.\" }", HttpStatus.BAD_REQUEST);
}
} catch (IllegalArgumentException e) {
- logger.error("Incorrect access type", e);
+ messageHandler.handleMessage("Incorrect access type.", e, MessageType.ERROR);
return new ResponseEntity("{\"error\": \"Incorrect access type.\" }", HttpStatus.BAD_REQUEST);
}
@@ -67,7 +72,7 @@ public ResponseEntity changeDocumentAccess(@RequestParam(defaultValue =
HttpStatus.OK);
}
} catch (UnstorableObjectException e) {
- logger.error("Could not save updated access type", e);
+ messageHandler.handleMessage("Could not save updated access type.", e, MessageType.ERROR);
return new ResponseEntity("{\"error\": \"Could not save updated access type.\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/DigilibPassthroughController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/DigilibPassthroughController.java
index 075c7a93..4434c6f0 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/DigilibPassthroughController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/DigilibPassthroughController.java
@@ -22,6 +22,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.ImageAccessCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.InjectImagePath;
import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
@@ -41,7 +43,9 @@ public class DigilibPassthroughController {
@Autowired
private DigilibConnector digilibConnector;
-
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
@ImageAccessCheck
@RequestMapping(value = "/rest/digilib")
@@ -90,12 +94,13 @@ public ResponseEntity passthroughToDigilib(
headers.put(key, digilibHeaders.get(key));
}
}
+
} catch (MalformedURLException e) {
- logger.error(e.getMessage(), e);
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(e.getMessage(),
HttpStatus.INTERNAL_SERVER_ERROR);
} catch (IOException e) {
- logger.error(e.getMessage(), e);
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(e.getMessage(),
HttpStatus.INTERNAL_SERVER_ERROR);
}
@@ -105,6 +110,7 @@ public ResponseEntity passthroughToDigilib(
try {
response.getOutputStream().close();
} catch (IOException e) {
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(e.getMessage(),
HttpStatus.INTERNAL_SERVER_ERROR);
}
@@ -161,11 +167,11 @@ public ResponseEntity passthroughToDigilibPublic(
}
}
} catch (MalformedURLException e) {
- logger.error(e.getMessage(), e);
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(e.getMessage(),
HttpStatus.INTERNAL_SERVER_ERROR);
} catch (IOException e) {
- logger.error(e.getMessage(), e);
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(e.getMessage(),
HttpStatus.INTERNAL_SERVER_ERROR);
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/FilesController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/FilesController.java
index 5e8751ee..a4788648 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/FilesController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/FilesController.java
@@ -24,6 +24,8 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.DocumentAccessCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.FileTokenAccessCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.TokenCheck;
@@ -66,6 +68,9 @@ public class FilesController {
@Autowired
private IJSONHelper jsonHelper;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
@TokenCheck
@RequestMapping(value = "/rest/files/uploads", produces = "application/json;charset=UTF-8")
@@ -92,7 +97,7 @@ public ResponseEntity getAllUploadsOfUser(@RequestParam(defaultValue = "
try {
mapper.writeValue(sw, root);
} catch (IOException e) {
- logger.error("Could not write json.", e);
+ messageHandler.handleMessage("Could not write json.", e, MessageType.ERROR);
return new ResponseEntity(
"{\"errorMsg\": \"Could not write json result.\", \"errorCode\": \"errorCode\": \"500\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
@@ -139,6 +144,7 @@ public ResponseEntity getUpload(
try {
mapper.writeValue(sw, root);
} catch (IOException e) {
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(
"{\"error\": \"Could not write json result.\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
@@ -167,6 +173,7 @@ public ResponseEntity getDocument(
try {
mapper.writeValue(sw, docNode);
} catch (IOException e) {
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return new ResponseEntity(
"{\"error\": \"Could not write json result.\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
@@ -206,7 +213,7 @@ public ResponseEntity getFile(
response.getOutputStream().write(content);
response.getOutputStream().close();
} catch (IOException e) {
- logger.error("Could not write to output stream.", e);
+ messageHandler.handleMessage("Could not write to output stream.", e, MessageType.ERROR);
return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/SearchController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/SearchController.java
index 1cdf0378..df9b5d3a 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/SearchController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/SearchController.java
@@ -5,8 +5,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -25,8 +23,6 @@
@Controller
public class SearchController {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private ISearchService searchService;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/UploadImagesController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/UploadImagesController.java
index b9c33ecc..bdf02808 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/UploadImagesController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/UploadImagesController.java
@@ -32,6 +32,8 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.TokenCheck;
import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
@@ -69,6 +71,9 @@ public class UploadImagesController {
@Autowired
private IGilesUrlHelper urlHelper;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@TokenCheck
@RequestMapping(value = "/rest/files/upload", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity uploadImages(
@@ -109,7 +114,7 @@ public ResponseEntity uploadImages(
try {
fileBytes.add(file.getBytes());
} catch (IOException e) {
- logger.error("Error reading bytes.", e);
+ messageHandler.handleMessage("Error reading bytes.", e, MessageType.ERROR);
Map msgs = new HashMap();
msgs.put("errorMsg", "File bytes could not be read.");
msgs.put("errorCode", "500");
@@ -186,7 +191,7 @@ public ResponseEntity checkAndGetResults(
try {
mapper.writeValue(sw, root);
} catch (IOException e) {
- logger.error("Could not write json.", e);
+ messageHandler.handleMessage("Could not write json.", e, MessageType.ERROR);
return new ResponseEntity(
"{\"error\": \"Could not write json result.\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
@@ -207,7 +212,7 @@ private ResponseEntity generateResponse(Map msgs, HttpSt
try {
mapper.writeValue(sw, root);
} catch (IOException e) {
- logger.error("Could not write json.", e);
+ messageHandler.handleMessage("Could not write json.", e, MessageType.ERROR);
return new ResponseEntity(
"{\"errorMsg\": \"Could not write json result.\", \"errorCode\": \"errorCode\": \"500\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/processing/TemporaryFilesController.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/processing/TemporaryFilesController.java
index 58faeb05..cdfb7502 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/processing/TemporaryFilesController.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/processing/TemporaryFilesController.java
@@ -5,8 +5,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -16,6 +14,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.AppTokenOnlyCheck;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
import edu.asu.diging.gilesecosystem.web.service.core.ITransactionalFileService;
@@ -28,14 +28,15 @@ public class TemporaryFilesController {
public final static String FILE_ID_PLACEHOLDER = "{fileId}";
public final static String GET_CONTENT_URL = "/rest/processing/files/" + FILE_ID_PLACEHOLDER + "/content";
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private ITransactionalFileService filesService;
@Autowired
private IDistributedStorageManager storageManager;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
@AppTokenOnlyCheck
@RequestMapping(value = GET_CONTENT_URL, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public ResponseEntity getFile(
@@ -58,7 +59,7 @@ public ResponseEntity getFile(
response.getOutputStream().write(content);
response.getOutputStream().close();
} catch (IOException e) {
- logger.error("Could not write to output stream.", e);
+ messageHandler.handleMessage("Could not write to output stream.", e, MessageType.ERROR);
return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/util/IJSONHelper.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/util/IJSONHelper.java
index abda2b47..a956ad1e 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/util/IJSONHelper.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/util/IJSONHelper.java
@@ -1,14 +1,11 @@
package edu.asu.diging.gilesecosystem.web.rest.util;
-import java.io.IOException;
-import java.io.StringWriter;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.node.ObjectNode;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/util/impl/JSONHelper.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/util/impl/JSONHelper.java
index 2c78002f..173c1851 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/util/impl/JSONHelper.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/rest/util/impl/JSONHelper.java
@@ -4,8 +4,6 @@
import java.io.StringWriter;
import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -16,6 +14,8 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
@@ -27,14 +27,15 @@
@Component
public class JSONHelper implements IJSONHelper {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private IFilesManager filesManager;
@Autowired
private ITransactionalFileService fileService;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
/* (non-Javadoc)
* @see edu.asu.giles.rest.util.IJSONHelper#createDocumentJson(edu.asu.giles.core.IDocument, com.fasterxml.jackson.databind.ObjectMapper, com.fasterxml.jackson.databind.node.ObjectNode)
*/
@@ -93,7 +94,7 @@ public ResponseEntity generateSimpleResponse(Map msgs, H
try {
mapper.writeValue(sw, root);
} catch (IOException e) {
- logger.error("Could not write json.", e);
+ messageHandler.handleMessage("Could not write json.", e, MessageType.ERROR);
return new ResponseEntity(
"{\"errorMsg\": \"Could not write json result.\", \"errorCode\": \"errorCode\": \"500\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/apps/impl/RegisteredAppsManager.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/apps/impl/RegisteredAppsManager.java
index 595eae55..69b99961 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/apps/impl/RegisteredAppsManager.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/apps/impl/RegisteredAppsManager.java
@@ -4,12 +4,12 @@
import java.util.Arrays;
import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredAppDatabaseClient;
@@ -22,14 +22,15 @@
@Service
public class RegisteredAppsManager implements IRegisteredAppManager {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private IRegisteredAppDatabaseClient databaseClient;
@Autowired
private ITokenService tokenService;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
/*
* (non-Javadoc)
*
@@ -54,7 +55,7 @@ public IRegisteredApp storeApp(IRegisteredApp app) {
try {
databaseClient.store(app);
} catch (UnstorableObjectException e) {
- logger.error("Could not store app.", e);
+ messageHandler.handleMessage("Could not store app.", e, MessageType.ERROR);
return null;
}
return app;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalDocumentService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalDocumentService.java
index 6e53c579..a543792c 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalDocumentService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalDocumentService.java
@@ -1,13 +1,11 @@
package edu.asu.diging.gilesecosystem.web.service.core;
-import java.util.ArrayList;
import java.util.List;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
import edu.asu.diging.gilesecosystem.web.domain.DocumentType;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
-import edu.asu.diging.gilesecosystem.web.domain.impl.Document;
public interface ITransactionalDocumentService {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalFileService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalFileService.java
index 9b89b840..04c9f99c 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalFileService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalFileService.java
@@ -1,7 +1,5 @@
package edu.asu.diging.gilesecosystem.web.service.core;
-import java.util.List;
-
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalUploadService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalUploadService.java
index 43474a5a..042edf33 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalUploadService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/core/ITransactionalUploadService.java
@@ -4,7 +4,6 @@
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.domain.IUpload;
-import edu.asu.diging.gilesecosystem.web.domain.impl.Upload;
public interface ITransactionalUploadService {
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/AbstractFileHandler.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/AbstractFileHandler.java
index 480e2544..e0c6e83b 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/AbstractFileHandler.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/AbstractFileHandler.java
@@ -7,27 +7,31 @@
import java.net.URL;
import java.net.URLConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
-import edu.asu.diging.gilesecosystem.web.files.IFileStorageManager;
+import edu.asu.diging.gilesecosystem.web.nepomuk.INepomukUrlService;
import edu.asu.diging.gilesecosystem.web.service.IFileContentHelper;
import edu.asu.diging.gilesecosystem.web.service.IFileTypeHandler;
import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
public abstract class AbstractFileHandler implements IFileTypeHandler {
- private Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
protected IPropertiesManager propertyManager;
@Autowired
protected IFileContentHelper fileContentHelper;
+ @Autowired
+ protected INepomukUrlService nepomukService;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
protected byte[] getFileContentFromUrl(URL url) throws IOException {
URLConnection con = url.openConnection();
@@ -55,11 +59,16 @@ protected byte[] getFileContentFromUrl(URL url) throws IOException {
@Override
public byte[] getFileContent(IFile file) {
try {
- return fileContentHelper.getFileContentFromUrl(new URL(file.getDownloadUrl()));
+ String downloadUrl = nepomukService.getFileDownloadPath(file);
+ if (downloadUrl == null) {
+ return null;
+ }
+
+ return fileContentHelper.getFileContentFromUrl(new URL(downloadUrl));
} catch (IOException e) {
- logger.error("Could not download file.", e);
+ messageHandler.handleMessage("Could not download file.", e, MessageType.ERROR);
return null;
- }
+ }
}
@Override
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/DefaultFileHandler.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/DefaultFileHandler.java
index 474ea96b..ce640794 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/DefaultFileHandler.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/DefaultFileHandler.java
@@ -3,27 +3,16 @@
import java.util.ArrayList;
import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;
import edu.asu.diging.gilesecosystem.requests.FileType;
-import edu.asu.diging.gilesecosystem.web.files.IFileStorageManager;
-import edu.asu.diging.gilesecosystem.web.files.IFilesDatabaseClient;
import edu.asu.diging.gilesecosystem.web.service.IFileTypeHandler;
@PropertySource("classpath:/config.properties")
@Service
public class DefaultFileHandler extends AbstractFileHandler implements IFileTypeHandler {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
- @Autowired
- private IFilesDatabaseClient databaseClient;
-
-
@Override
public List getHandledFileTypes() {
List types = new ArrayList();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/ImageFileHandler.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/ImageFileHandler.java
index 77aacb20..61c0cf68 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/ImageFileHandler.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/ImageFileHandler.java
@@ -5,25 +5,22 @@
import java.util.ArrayList;
import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import edu.asu.diging.gilesecosystem.requests.FileType;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
-import edu.asu.diging.gilesecosystem.web.files.IFilesDatabaseClient;
import edu.asu.diging.gilesecosystem.web.service.IFileTypeHandler;
import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
@Service
public class ImageFileHandler extends AbstractFileHandler implements IFileTypeHandler {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
- private IFilesDatabaseClient filesDbClient;
+ private ISystemMessageHandler messageHandler;
@Override
public List getHandledFileTypes() {
@@ -52,7 +49,7 @@ public String getFileUrl(IFile file) {
try {
return gilesUrl + gilesDigilibEndpoint + "?fn=" + URLEncoder.encode(relativePath, "UTF-8");
} catch (UnsupportedEncodingException e) {
- logger.error("Could not encode path.", e);
+ messageHandler.handleMessage("Could not encode path.", e, MessageType.ERROR);
return gilesUrl + gilesDigilibEndpoint + "?fn=" + relativePath;
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/PdfFileHandler.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/PdfFileHandler.java
index 276c3a3e..a7d6d66d 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/PdfFileHandler.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/handlers/PdfFileHandler.java
@@ -5,17 +5,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import edu.asu.diging.gilesecosystem.requests.FileType;
-import edu.asu.diging.gilesecosystem.requests.IRequestFactory;
-import edu.asu.diging.gilesecosystem.requests.IStorageRequest;
-import edu.asu.diging.gilesecosystem.requests.impl.StorageRequest;
-import edu.asu.diging.gilesecosystem.web.files.IDocumentDatabaseClient;
-import edu.asu.diging.gilesecosystem.web.files.IFilesDatabaseClient;
import edu.asu.diging.gilesecosystem.web.service.IFileTypeHandler;
@PropertySource("classpath:/config.properties")
@@ -24,15 +18,6 @@ public class PdfFileHandler extends AbstractFileHandler implements IFileTypeHand
final Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private IFilesDatabaseClient filesDbClient;
-
- @Autowired
- private IDocumentDatabaseClient documentsDbClient;
-
- @Autowired
- private IRequestFactory requestFactory;
-
@Override
public List getHandledFileTypes() {
List types = new ArrayList();
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/impl/FileContentHelper.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/impl/FileContentHelper.java
index 8bc62408..52c32ce4 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/impl/FileContentHelper.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/impl/FileContentHelper.java
@@ -8,10 +8,11 @@
import java.net.URL;
import java.net.URLConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
import edu.asu.diging.gilesecosystem.web.files.IFileStorageManager;
import edu.asu.diging.gilesecosystem.web.service.IFileContentHelper;
@@ -19,7 +20,8 @@
@Component
public class FileContentHelper implements IFileContentHelper {
- private final Logger logger = LoggerFactory.getLogger(getClass());
+ @Autowired
+ private ISystemMessageHandler messageHandler;
/* (non-Javadoc)
* @see edu.asu.giles.service.impl.IFileSystemHelper#getFileContent(edu.asu.giles.core.IFile, edu.asu.giles.files.IFileStorageManager)
@@ -31,7 +33,7 @@ public byte[] getFileContent(IFile file, IFileStorageManager storageManager) {
try {
return getFileContentFromUrl(fileObject.toURI().toURL());
} catch (IOException e) {
- logger.error("Could not read file.", e);
+ messageHandler.handleMessage("Could not read file.", e, MessageType.ERROR);
return null;
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ACompletedExtractionProcessor.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ACompletedExtractionProcessor.java
index 13de7632..37b57744 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ACompletedExtractionProcessor.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ACompletedExtractionProcessor.java
@@ -9,6 +9,8 @@
import edu.asu.diging.gilesecosystem.requests.IStorageRequest;
import edu.asu.diging.gilesecosystem.requests.exceptions.MessageCreationException;
import edu.asu.diging.gilesecosystem.requests.kafka.IRequestProducer;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
@@ -44,7 +46,9 @@ public abstract class ACompletedExtractionProcessor extends ACompletedRequestPro
@Autowired
private IUserManager userManager;
-
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
protected void sendRequest(IFile file, String downloadPath, String downloadUrl, FileType type) {
IStorageRequest storageRequest;
@@ -53,7 +57,7 @@ protected void sendRequest(IFile file, String downloadPath, String downloadUrl,
} catch (GilesProcessingException e) {
// should not happen
// FIXME: send to monitor app
- logger.error("Could not create request.", e);
+ messageHandler.handleMessage("Could not create request.", e, MessageType.ERROR);
return;
}
@@ -68,7 +72,7 @@ protected void sendRequest(IFile file, String downloadPath, String downloadUrl,
requestProducer.sendRequest(storageRequest, propertyManager.getProperty(Properties.KAFKA_TOPIC_STORAGE_REQUEST));
} catch (MessageCreationException e) {
// FIXME: send to monitor app
- logger.error("Could not send message.", e);
+ messageHandler.handleMessage("Could not send message.", e, MessageType.ERROR);
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ACompletedRequestProcessor.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ACompletedRequestProcessor.java
index a23add89..c77c85a6 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ACompletedRequestProcessor.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ACompletedRequestProcessor.java
@@ -7,6 +7,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import edu.asu.diging.gilesecosystem.requests.IRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.domain.IProcessingRequest;
import edu.asu.diging.gilesecosystem.web.service.core.ITransactionalProcessingRequestService;
@@ -17,6 +19,9 @@ public abstract class ACompletedRequestProcessor {
@Autowired
private ITransactionalProcessingRequestService pReqDbClient;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
protected void markRequestComplete(IRequest completeRequest) {
List pRequests = pReqDbClient.getProcRequestsByRequestId(completeRequest.getRequestId());
@@ -28,7 +33,7 @@ protected void markRequestComplete(IRequest completeRequest) {
} catch (UnstorableObjectException e) {
// should never happen
// FIXME send to monitoring app
- logger.error("Could not store request.", e);
+ messageHandler.handleMessage("Could not store request.", e, MessageType.ERROR);
}
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedImageExtractionProcessor.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedImageExtractionProcessor.java
index 541b0456..715f87d8 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedImageExtractionProcessor.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedImageExtractionProcessor.java
@@ -10,6 +10,8 @@
import edu.asu.diging.gilesecosystem.requests.ICompletedImageExtractionRequest;
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
import edu.asu.diging.gilesecosystem.requests.impl.CompletedImageExtractionRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
@@ -41,7 +43,9 @@ public class CompletedImageExtractionProcessor extends ACompletedExtractionProce
@Autowired
private IPropertiesManager propertiesManager;
-
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
/* (non-Javadoc)
* @see edu.asu.diging.gilesecosystem.web.service.processing.impl.ICompletedTextExtractionProcessor#processCompletedRequest(edu.asu.diging.gilesecosystem.requests.ICompletedTextExtractionRequest)
@@ -63,7 +67,7 @@ public void processRequest(ICompletedImageExtractionRequest request) {
filesService.saveFile(pageText);
} catch (UnstorableObjectException e) {
// should never happen, we're setting the id
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
}
IPage documentPage = pages.get(page.getPageNr());
@@ -88,7 +92,7 @@ public void processRequest(ICompletedImageExtractionRequest request) {
try {
filesService.saveFile(file);
} catch (UnstorableObjectException e) {
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
// fail silently...
// this should never happen
}
@@ -98,14 +102,14 @@ public void processRequest(ICompletedImageExtractionRequest request) {
} catch (UnstorableObjectException e) {
// shoudl never happen
// report to monitoring app
- logger.error("Could not store document.", e);
+ messageHandler.handleMessage("Could not store document.", e, MessageType.ERROR);
}
try {
processCoordinator.processFile(file, null);
} catch (GilesProcessingException e) {
// FIXME: send to monitoring app
- logger.error("Processing failed.", e);
+ messageHandler.handleMessage("Processing failed.", e, MessageType.ERROR);
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedOCRProcessor.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedOCRProcessor.java
index 5a7b3b3a..df513867 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedOCRProcessor.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedOCRProcessor.java
@@ -12,6 +12,8 @@
import edu.asu.diging.gilesecosystem.requests.ICompletedOCRRequest;
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
import edu.asu.diging.gilesecosystem.requests.impl.CompletedOCRRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
@@ -43,7 +45,9 @@ public class CompletedOCRProcessor extends ACompletedExtractionProcessor impleme
@Autowired
private IPropertiesManager propertiesManager;
-
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
/* (non-Javadoc)
* @see edu.asu.diging.gilesecosystem.web.service.processing.impl.ICompletedTextExtractionProcessor#processCompletedRequest(edu.asu.diging.gilesecosystem.requests.ICompletedTextExtractionRequest)
@@ -60,7 +64,7 @@ public void processRequest(ICompletedOCRRequest request) {
filesService.saveFile(pageText);
} catch (UnstorableObjectException e) {
// should never happen, we're setting the id
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
}
// we are looking for the image that was ocred
@@ -88,7 +92,7 @@ public void processRequest(ICompletedOCRRequest request) {
try {
filesService.saveFile(file);
} catch (UnstorableObjectException e) {
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
// fail silently...
// this should never happen
}
@@ -98,14 +102,14 @@ public void processRequest(ICompletedOCRRequest request) {
} catch (UnstorableObjectException e) {
// shoudl never happen
// report to monitoring app
- logger.error("Could not store document.", e);
+ messageHandler.handleMessage("Could not store document.", e, MessageType.ERROR);
}
try {
processCoordinator.processFile(file, null);
} catch (GilesProcessingException e) {
// FIXME: send to monitoring app
- logger.error("Processing failed.", e);
+ messageHandler.handleMessage("Processing failed.", e, MessageType.ERROR);
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedStorageRequestProcessor.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedStorageRequestProcessor.java
index 27be0ac8..75d46ae3 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedStorageRequestProcessor.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedStorageRequestProcessor.java
@@ -1,7 +1,5 @@
package edu.asu.diging.gilesecosystem.web.service.processing.impl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@@ -9,6 +7,8 @@
import edu.asu.diging.gilesecosystem.requests.ICompletedStorageRequest;
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
import edu.asu.diging.gilesecosystem.requests.impl.CompletedStorageRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
@@ -24,8 +24,6 @@
@Service
public class CompletedStorageRequestProcessor extends ACompletedRequestProcessor implements RequestProcessor, ICompletedStorageRequestProcessor {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
@Qualifier("tmpStorageManager")
private IFileStorageManager storageManager;
@@ -39,6 +37,8 @@ public class CompletedStorageRequestProcessor extends ACompletedRequestProcessor
@Autowired
private IPropertiesManager propertiesManager;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
/* (non-Javadoc)
* @see edu.asu.diging.gilesecosystem.web.service.processing.impl.ICompletedStorageRequestProcessor#processCompletedRequest(edu.asu.diging.gilesecosystem.requests.ICompletedStorageRequest)
@@ -62,7 +62,7 @@ public void processRequest(ICompletedStorageRequest request) {
try {
filesService.saveFile(file);
} catch (UnstorableObjectException e) {
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
// fail silently...
// this should never happen
}
@@ -71,7 +71,7 @@ public void processRequest(ICompletedStorageRequest request) {
processCoordinator.processFile(file, null);
} catch (GilesProcessingException e) {
//FIXME: this should go in a monitoring app
- logger.error("Exception occured in next processing phase.", e);
+ messageHandler.handleMessage("Exception occured in next processing phase.", e, MessageType.ERROR);
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedTextExtractionProcessor.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedTextExtractionProcessor.java
index 021db1c1..a60113bd 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedTextExtractionProcessor.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletedTextExtractionProcessor.java
@@ -8,6 +8,8 @@
import edu.asu.diging.gilesecosystem.requests.ICompletedTextExtractionRequest;
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
import edu.asu.diging.gilesecosystem.requests.impl.CompletedTextExtractionRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
@@ -39,7 +41,9 @@ public class CompletedTextExtractionProcessor extends ACompletedExtractionProces
@Autowired
private IPropertiesManager propertiesManager;
-
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
/* (non-Javadoc)
* @see edu.asu.diging.gilesecosystem.web.service.processing.impl.ICompletedTextExtractionProcessor#processCompletedRequest(edu.asu.diging.gilesecosystem.requests.ICompletedTextExtractionRequest)
@@ -59,7 +63,7 @@ public void processRequest(ICompletedTextExtractionRequest request) {
filesService.saveFile(completeText);
} catch (UnstorableObjectException e) {
// should never happen, we're setting the id
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
}
document.setExtractedTextFileId(completeText.getId());
@@ -77,7 +81,7 @@ public void processRequest(ICompletedTextExtractionRequest request) {
filesService.saveFile(pageText);
} catch (UnstorableObjectException e) {
// should never happen, we're setting the id
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
}
IPage documentPage = new Page();
@@ -97,7 +101,7 @@ public void processRequest(ICompletedTextExtractionRequest request) {
try {
filesService.saveFile(file);
} catch (UnstorableObjectException e) {
- logger.error("Could not store file.", e);
+ messageHandler.handleMessage("Could not store file.", e, MessageType.ERROR);
// fail silently...
// this should never happen
}
@@ -107,14 +111,14 @@ public void processRequest(ICompletedTextExtractionRequest request) {
} catch (UnstorableObjectException e) {
// shoudl never happen
// report to monitoring app
- logger.error("Could not store document.", e);
+ messageHandler.handleMessage("Could not store document.", e, MessageType.ERROR);
}
try {
processCoordinator.processFile(file, null);
} catch (GilesProcessingException e) {
// FIXME: send to monitoring app
- logger.error("Processing failed.", e);
+ messageHandler.handleMessage("Processing failed.", e, MessageType.ERROR);
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletionNotificationProcessor.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletionNotificationProcessor.java
index ff09580d..1ffaef92 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletionNotificationProcessor.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/CompletionNotificationProcessor.java
@@ -2,13 +2,13 @@
import java.util.ArrayList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import edu.asu.diging.gilesecosystem.requests.ICompletionNotificationRequest;
import edu.asu.diging.gilesecosystem.requests.impl.CompletionNotificationRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
@@ -21,13 +21,14 @@
@Service
public class CompletionNotificationProcessor implements RequestProcessor {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private IPropertiesManager propertiesManager;
@Autowired
private ITransactionalDocumentService documentService;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
@Override
public String getProcessedTopic() {
@@ -51,7 +52,7 @@ public void processRequest(ICompletionNotificationRequest request) {
documentService.saveDocument(document);
} catch (UnstorableObjectException e) {
// should never happen
- logger.error("Could not store document.", e);
+ messageHandler.handleMessage("Could not store document.", e, MessageType.ERROR);
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/FileProcessingCoordinator.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/FileProcessingCoordinator.java
index d0ac3393..b730a5c6 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/FileProcessingCoordinator.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/FileProcessingCoordinator.java
@@ -15,7 +15,6 @@
import edu.asu.diging.gilesecosystem.web.domain.IFile;
import edu.asu.diging.gilesecosystem.web.domain.ProcessingStatus;
import edu.asu.diging.gilesecosystem.web.exceptions.GilesProcessingException;
-import edu.asu.diging.gilesecosystem.web.service.processing.IDistributedStorageManager;
import edu.asu.diging.gilesecosystem.web.service.processing.IProcessingCoordinator;
import edu.asu.diging.gilesecosystem.web.service.processing.IProcessingInfo;
import edu.asu.diging.gilesecosystem.web.service.processing.IProcessingPhase;
@@ -27,9 +26,6 @@ public class FileProcessingCoordinator implements IProcessingCoordinator {
@Autowired
private ApplicationContext ctx;
- @Autowired
- private IDistributedStorageManager distributedStorageManager;
-
private Map> processingPhases;
private Map processChain;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ImageExtractionRequestPhase.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ImageExtractionRequestPhase.java
index a62fee39..6d98b26f 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ImageExtractionRequestPhase.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ImageExtractionRequestPhase.java
@@ -15,6 +15,7 @@
import edu.asu.diging.gilesecosystem.web.domain.IFile;
import edu.asu.diging.gilesecosystem.web.domain.ProcessingStatus;
import edu.asu.diging.gilesecosystem.web.exceptions.GilesProcessingException;
+import edu.asu.diging.gilesecosystem.web.nepomuk.INepomukUrlService;
import edu.asu.diging.gilesecosystem.web.service.core.ITransactionalFileService;
import edu.asu.diging.gilesecosystem.web.service.processing.IProcessingInfo;
import edu.asu.diging.gilesecosystem.web.service.processing.ProcessingPhaseName;
@@ -34,6 +35,9 @@ public class ImageExtractionRequestPhase extends ProcessingPhase {
@Autowired
private ITransactionalFileService filesService;
+ @Autowired
+ private INepomukUrlService nepomukService;
+
@PostConstruct
public void init() {
requestFactory.config(OCRRequest.class);
@@ -58,7 +62,7 @@ protected IRequest createRequest(IFile file, IProcessingInfo info)
}
request.setDocumentId(file.getDocumentId());
- request.setDownloadUrl(file.getDownloadUrl());
+ request.setDownloadUrl(nepomukService.getFileDownloadPath(file));
request.setDownloadPath(file.getFilepath());
request.setStatus(RequestStatus.SUBMITTED);
request.setFilename(file.getFilename());
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ProcessingPhase.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ProcessingPhase.java
index 25c9bd9c..5a9fea06 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ProcessingPhase.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/ProcessingPhase.java
@@ -1,13 +1,13 @@
package edu.asu.diging.gilesecosystem.web.service.processing.impl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import edu.asu.diging.gilesecosystem.requests.IRequest;
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
import edu.asu.diging.gilesecosystem.requests.exceptions.MessageCreationException;
import edu.asu.diging.gilesecosystem.requests.kafka.IRequestProducer;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
@@ -24,8 +24,6 @@
public abstract class ProcessingPhase implements IProcessingPhase {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private ITransactionalDocumentService documentService;
@@ -40,7 +38,9 @@ public abstract class ProcessingPhase implements IPro
@Autowired
private IProcessingCoordinator processCoordinator;
-
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
public RequestStatus process(IFile file, IProcessingInfo info)
throws GilesProcessingException {
@@ -49,7 +49,7 @@ public RequestStatus process(IFile file, IProcessingInfo info)
try {
request = createRequest(file, info);
} catch (GilesProcessingException ex) {
- logger.error("Could not create request.", ex);
+ messageHandler.handleMessage("Could not create request.", ex, MessageType.ERROR);
return RequestStatus.FAILED;
}
@@ -66,7 +66,7 @@ public RequestStatus process(IFile file, IProcessingInfo info)
return status;
} catch (GilesProcessingException e) {
//FIXME: this should go in a monitoring app
- logger.error("Exception occured in next processing phase.", e);
+ messageHandler.handleMessage("Exception occured in next processing phase.", e, MessageType.ERROR);
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/RequestResender.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/RequestResender.java
index fbdd22ab..f72b3b79 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/RequestResender.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/RequestResender.java
@@ -10,8 +10,6 @@
import javax.annotation.PostConstruct;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Async;
@@ -19,6 +17,8 @@
import org.springframework.stereotype.Service;
import edu.asu.diging.gilesecosystem.requests.IRequest;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
import edu.asu.diging.gilesecosystem.web.domain.IProcessingRequest;
import edu.asu.diging.gilesecosystem.web.exceptions.GilesProcessingException;
@@ -31,8 +31,6 @@
@Service
public class RequestResender implements IRequestResender {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private ApplicationContext ctx;
@@ -41,6 +39,9 @@ public class RequestResender implements IRequestResender {
@Autowired
private ITransactionalDocumentService documentService;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
private Map, ProcessingPhase extends IProcessingInfo>> phaseMap;
@@ -78,7 +79,7 @@ public Future resendRequests() {
counter++;
} catch (GilesProcessingException e) {
// FIXME: send to september
- logger.error("Could not send request.", e);
+ messageHandler.handleMessage("Could not send request.", e, MessageType.ERROR);
}
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/TextExtractionRequestPhase.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/TextExtractionRequestPhase.java
index fc462c2e..2c3e30f4 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/TextExtractionRequestPhase.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/processing/impl/TextExtractionRequestPhase.java
@@ -15,6 +15,7 @@
import edu.asu.diging.gilesecosystem.web.domain.IFile;
import edu.asu.diging.gilesecosystem.web.domain.ProcessingStatus;
import edu.asu.diging.gilesecosystem.web.exceptions.GilesProcessingException;
+import edu.asu.diging.gilesecosystem.web.nepomuk.INepomukUrlService;
import edu.asu.diging.gilesecosystem.web.service.core.ITransactionalFileService;
import edu.asu.diging.gilesecosystem.web.service.processing.IProcessingInfo;
import edu.asu.diging.gilesecosystem.web.service.processing.ProcessingPhaseName;
@@ -34,6 +35,9 @@ public class TextExtractionRequestPhase extends ProcessingPhase
@Autowired
private IPropertiesManager propertyManager;
+ @Autowired
+ private INepomukUrlService nepomukService;
+
@PostConstruct
public void init() {
requestFactory.config(TextExtractionRequest.class);
@@ -54,7 +58,7 @@ public IRequest createRequest(IFile file, IProcessingInfo info) throws GilesProc
}
request.setDocumentId(file.getDocumentId());
- request.setDownloadUrl(file.getDownloadUrl());
+ request.setDownloadUrl(nepomukService.getFileDownloadPath(file));
request.setStatus(RequestStatus.SUBMITTED);
request.setFilename(file.getFilename());
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/properties/Properties.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/properties/Properties.java
index 80f8cc6a..f4ebc505 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/properties/Properties.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/properties/Properties.java
@@ -74,4 +74,15 @@ public interface Properties {
public final static String EXTERNAL_BADGE_PREFIX = "processor_prefix";
public final static String EXTERNAL_BADGE_COLOR_PREFIX = "processor_color_prefix";
+
+ public final static String EMAIL_ENABLED = "email_enabled";
+ public final static String EMAIL_FROM = "email_from";
+
+ public final static String ZOOKEEPER_HOST = "zookeeper_host";
+ public final static String ZOOKEEPER_PORT = "zookeeper_port";
+
+ public final static String ZOOKEEPER_NEPOMUK_SERVICE_NAME = "zookeeepr_service_nepomuk_name";
+
+ public final static String NEPOMUK_PING_ENDPOINT = "nepomuk_ping_endpoint";
+ public final static String NEPOMUK_FILES_ENDPOINT = "nepomuk_files_endpoint";
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/search/impl/FileSearchResultFactory.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/search/impl/FileSearchResultFactory.java
index 02ccf14e..b0409061 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/search/impl/FileSearchResultFactory.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/search/impl/FileSearchResultFactory.java
@@ -35,6 +35,10 @@ public class FileSearchResultFactory implements IFileSearchResultFactory {
public FileSearchResult createSearchResult(String fileId) {
IFile file = fileService.getFileById(fileId);
+ if (file == null) {
+ return null;
+ }
+
FileSearchResult result = new FileSearchResult();
result.setAccess(file.getAccess());
result.setContentType(file.getContentType());
@@ -55,10 +59,12 @@ public FileSearchResult createSearchResult(String fileId) {
result.setPage(-1);
} else {
// if at any point not just text files get index, this should cover all cases
- Optional optional = document.getPages().stream().filter(p -> p.getTextFileId().equals(fileId) || p.getOcrFileId().equals(fileId) || p.getImageFileId().equals(fileId)).findFirst();
- if (optional.isPresent()) {
- IPage page = optional.get();
- result.setPage(page.getPageNr());
+ if (document.getPages() != null) {
+ Optional optional = document.getPages().stream().filter(p -> p.getTextFileId().equals(fileId) || p.getOcrFileId().equals(fileId) || p.getImageFileId().equals(fileId)).findFirst();
+ if (optional.isPresent()) {
+ IPage page = optional.get();
+ result.setPage(page.getPageNr());
+ }
}
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/search/impl/SearchService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/search/impl/SearchService.java
index f7f5de87..b92cb195 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/search/impl/SearchService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/service/search/impl/SearchService.java
@@ -31,7 +31,10 @@ public List searchWithUsername(String username, String query)
List fileResults = new ArrayList();
for (SearchResult result : results) {
- fileResults.add(fileResultFactory.createSearchResult(result.getFileId()));
+ FileSearchResult searchResult = fileResultFactory.createSearchResult(result.getFileId());
+ if (searchResult != null) {
+ fileResults.add(searchResult);
+ }
}
return fileResults;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/ITokenService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/ITokenService.java
index 0af399cf..dd858c49 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/ITokenService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/ITokenService.java
@@ -1,11 +1,6 @@
package edu.asu.diging.gilesecosystem.web.tokens;
-import io.jsonwebtoken.Claims;
-import io.jsonwebtoken.Jws;
-import io.jsonwebtoken.Jwts;
-import io.jsonwebtoken.SignatureException;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredApp;
-import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
import edu.asu.diging.gilesecosystem.web.users.User;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/IntrospectTokenService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/IntrospectTokenService.java
index 9ed0bdcb..bc49bcba 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/IntrospectTokenService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/IntrospectTokenService.java
@@ -2,11 +2,11 @@
import java.util.Date;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
@@ -15,8 +15,10 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
-import edu.asu.diging.gilesecosystem.web.config.GilesTokenConfig;
import edu.asu.diging.gilesecosystem.web.exceptions.ServerMisconfigurationException;
import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
import edu.asu.diging.gilesecosystem.web.tokens.IApiTokenContents;
@@ -41,7 +43,7 @@ public class IntrospectTokenService implements IIntrospectTokenService {
private RestTemplate accessTokenRestTemplate;
@Autowired
- private GilesTokenConfig tokenConfig;
+ private ISystemMessageHandler messageHandler;
public IApiTokenContents introspectAccessToken(String accessToken) throws ServerMisconfigurationException {
@@ -57,8 +59,7 @@ public IApiTokenContents introspectAccessToken(String accessToken) throws Server
try {
validatedToken = accessTokenRestTemplate.postForObject(introspectionUrl, form, String.class);
} catch (RestClientException rce) {
- logger.error("introspect access token validation", rce);
- tokenConfig.getMessageHandler().handleError("introspect access token validation", rce);
+ messageHandler.handleMessage("introspect access token validation", rce, MessageType.ERROR);
return null;
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/NimbusTokenService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/NimbusTokenService.java
index 1503c87d..2db4b14e 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/NimbusTokenService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/NimbusTokenService.java
@@ -24,6 +24,8 @@
import com.nimbusds.openid.connect.sdk.claims.IDTokenClaimsSet;
import com.nimbusds.openid.connect.sdk.validators.IDTokenValidator;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.web.exceptions.AppMisconfigurationException;
@@ -44,6 +46,9 @@ public class NimbusTokenService implements INimbusTokenService {
@Autowired
private IRegisteredAppManager appsManager;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
private String issuerUrl;
@@ -101,10 +106,10 @@ public IApiTokenContents getOpenIdToken(String token, String appId) throws Ident
try {
claims = validator.validate(idToken, expectedNonce);
} catch (BadJOSEException e) {
- logger.warn("Token signature or claim is wrong.", e);
+ messageHandler.handleMessage("Token signature or claim is wrong.", e, MessageType.WARNING);
return null;
} catch (JOSEException e) {
- logger.error("Could not validate token.", e);
+ messageHandler.handleMessage("Could not validate token.", e, MessageType.ERROR);
return null;
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/TokenService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/TokenService.java
index fc19a7b1..c900c150 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/TokenService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/tokens/impl/TokenService.java
@@ -1,19 +1,13 @@
package edu.asu.diging.gilesecosystem.web.tokens.impl;
-import io.jsonwebtoken.Claims;
-import io.jsonwebtoken.Jws;
-import io.jsonwebtoken.Jwts;
-import io.jsonwebtoken.SignatureAlgorithm;
-import io.jsonwebtoken.SignatureException;
-
import java.util.Date;
import java.util.UUID;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
@@ -21,6 +15,11 @@
import edu.asu.diging.gilesecosystem.web.tokens.IAppToken;
import edu.asu.diging.gilesecosystem.web.tokens.ITokenService;
import edu.asu.diging.gilesecosystem.web.users.User;
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.Jws;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+import io.jsonwebtoken.SignatureException;
/**
* Class to create new user tokens for access to the REST api.
@@ -31,8 +30,6 @@
@Service
public class TokenService implements ITokenService {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
/**
* 4 hours
*/
@@ -41,6 +38,9 @@ public class TokenService implements ITokenService {
@Autowired
private IPropertiesManager propertiesManager;
+ @Autowired
+ private ISystemMessageHandler messageHandler;
+
/* (non-Javadoc)
* @see edu.asu.giles.tokens.impl.ITokenService#generateToken(java.lang.String)
*/
@@ -71,10 +71,10 @@ public IApiTokenContents getApiTokenContents(String token) {
contents.setExpired(expirationTime.before(new Date()));
}
} catch (io.jsonwebtoken.ExpiredJwtException e) {
- logger.info("Token is expired.", e);
+ messageHandler.handleMessage("Token is expired.", e, MessageType.INFO);
contents.setExpired(true);
} catch (SignatureException e) {
- logger.warn("Token signature not correct.", e);
+ messageHandler.handleMessage("Token signature not correct.", e, MessageType.WARNING);
return null;
}
@@ -117,8 +117,10 @@ public IAppToken getAppTokenContents(String token) {
} catch (io.jsonwebtoken.ExpiredJwtException e) {
// currently app tokens don't expire, so we'll just return null
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return null;
} catch (SignatureException e) {
+ messageHandler.handleMessage(e.getMessage(), e, MessageType.ERROR);
return null;
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/User.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/User.java
index d76840ba..d3c9cf62 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/User.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/User.java
@@ -4,12 +4,10 @@
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Basic;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
-import javax.persistence.OneToMany;
@Entity
public class User implements Serializable {
@@ -99,10 +97,6 @@ public void setRoles(List roles) {
this.roles = roles;
}
- public void setAdmin(boolean isAdmin) {
- this.isAdmin = isAdmin;
- }
-
public String getFullname() {
if (name != null && !name.isEmpty()) {
return name;
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/UserDatabaseClient.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/UserDatabaseClient.java
index 3b991e98..2e61c1c6 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/UserDatabaseClient.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/UserDatabaseClient.java
@@ -6,6 +6,10 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -100,7 +104,7 @@ public void update(User user) {
User storedUser = findUserByProviderUserId(user.getUserIdOfProvider(), user.getProvider());
storedUser.setAccountStatus(user.getAccountStatus());
- storedUser.setAdmin(user.getIsAdmin());
+ storedUser.setIsAdmin(user.getIsAdmin());
storedUser.setEmail(user.getEmail());
storedUser.setFirstname(user.getFirstname());
storedUser.setLastname(user.getLastname());
@@ -117,6 +121,22 @@ protected List searchByProperty(String propName, String propValue) {
return docs.getResultList();
}
+ /**
+ * Find users based on role.
+ *
+ * @param role role of the user
+ * @return list of users with input role
+ */
+ protected List getUsersByRole(String role) {
+ CriteriaBuilder builder = em.getCriteriaBuilder();
+ CriteriaQuery criteriaQuery = builder.createQuery(User.class);
+ Root user = criteriaQuery.from(User.class);
+ Predicate hasUserRole = builder.and(user.join("roles").in(role));
+ criteriaQuery.where(hasUserRole);
+ TypedQuery userList = em.createQuery(criteriaQuery);
+ return userList.getResultList();
+ }
+
/**
* This methods generates a new 6 character long id. Note that this method
* does not assure that the id isn't in use yet.
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/UsersManager.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/UsersManager.java
index f1a10097..124173c4 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/UsersManager.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/UsersManager.java
@@ -3,10 +3,16 @@
import java.util.ArrayList;
import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
+import edu.asu.diging.gilesecosystem.web.email.IEmailNotificationManager;
+import edu.asu.diging.gilesecosystem.web.exceptions.GilesNotificationException;
/**
* Managing class for user management.
@@ -17,9 +23,16 @@
@Service
public class UsersManager implements IUserManager {
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
@Autowired
private UserDatabaseClient client;
+ @Autowired
+ private IEmailNotificationManager emailManager;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
/*
* (non-Javadoc)
*
@@ -76,6 +89,16 @@ public User[] getAllUsers() {
@Override
public User addUser(User user) throws UnstorableObjectException {
client.addUser(user);
+ //send notification to all admins
+ List adminList = client.getUsersByRole(GilesRole.ROLE_ADMIN.name());
+ for(User admin : adminList) {
+ try {
+ emailManager.sendAccountCreatedEmail(user.getName(), user.getUsername(), admin.getFullname(), admin.getEmail());
+ } catch (GilesNotificationException e) {
+ // let's log warning but keep on going
+ messageHandler.handleMessage("Email to " + admin.getUsername() + " could not be sent.", e, MessageType.WARNING);
+ }
+ }
return user;
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/impl/AdminUserDetailsService.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/impl/AdminUserDetailsService.java
index e624bd9c..f8fcb297 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/impl/AdminUserDetailsService.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/users/impl/AdminUserDetailsService.java
@@ -11,8 +11,7 @@
import javax.annotation.PostConstruct;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.PathResource;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
@@ -23,6 +22,8 @@
import org.springframework.util.DefaultPropertiesPersister;
import org.springframework.util.PropertiesPersister;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.users.GilesGrantedAuthority;
import edu.asu.diging.gilesecosystem.web.users.IAdminUserDetailsService;
@@ -35,7 +36,8 @@
@Service("adminDetailsService")
public class AdminUserDetailsService implements IAdminUserDetailsService {
- private final Logger logger = LoggerFactory.getLogger(getClass());
+ @Autowired
+ private ISystemMessageHandler messageHandler;
private PropertiesPersister persister;
private Properties users;
@@ -105,7 +107,7 @@ public boolean changePassword(String username, String password) {
try {
persister.store(users, customPropsResource.getOutputStream(), "");
} catch (IOException e) {
- logger.error("Could not store properties.", e);
+ messageHandler.handleMessage("Could not store properties.", e, MessageType.ERROR);
return false;
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/util/FileUploadHelper.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/util/FileUploadHelper.java
index 09c5f938..12623518 100755
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/util/FileUploadHelper.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/util/FileUploadHelper.java
@@ -6,12 +6,12 @@
import java.util.Map;
import org.apache.tika.Tika;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
import edu.asu.diging.gilesecosystem.web.domain.DocumentType;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
@@ -23,10 +23,11 @@
@Service
public class FileUploadHelper {
- private Logger logger = LoggerFactory.getLogger(getClass());
-
@Autowired
private IFilesManager filesManager;
+
+ @Autowired
+ private ISystemMessageHandler messageHandler;
public List processUpload(DocumentAccess access, DocumentType docType,
MultipartFile[] files, List fileBytes, User user,
@@ -52,7 +53,7 @@ public List processUpload(DocumentAccess access, DocumentType doc
uploadedFiles.put(file, bytes);
} catch (IOException e2) {
- logger.error("Couldn't get file content.", e2);
+ messageHandler.handleMessage("Couldn't get file content.", e2, MessageType.ERROR);
uploadedFiles.put(file, null);
}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/util/IStatusHelper.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/util/IStatusHelper.java
index eaf40ee7..dab5f99e 100644
--- a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/util/IStatusHelper.java
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/util/IStatusHelper.java
@@ -1,12 +1,9 @@
package edu.asu.diging.gilesecosystem.web.util;
-import java.util.List;
-
import edu.asu.diging.gilesecosystem.requests.IRequest;
import edu.asu.diging.gilesecosystem.requests.RequestStatus;
import edu.asu.diging.gilesecosystem.web.domain.IDocument;
import edu.asu.diging.gilesecosystem.web.domain.IFile;
-import edu.asu.diging.gilesecosystem.web.domain.IProcessingRequest;
/**
* Implementations of this interface provide support for calculating statuses of
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/velocity/IVelocityBuilder.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/velocity/IVelocityBuilder.java
new file mode 100644
index 00000000..d839697d
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/velocity/IVelocityBuilder.java
@@ -0,0 +1,17 @@
+package edu.asu.diging.gilesecosystem.web.velocity;
+
+import java.util.Map;
+
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+
+/**
+ * The purpose of this interface is to update template with provided data.
+ *
+ * @author snilapwa
+ */
+public interface IVelocityBuilder {
+
+ String getRenderedTemplate(String templateName, Map contextProperties)
+ throws ResourceNotFoundException, ParseErrorException, Exception;
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/velocity/impl/VelocityBuilder.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/velocity/impl/VelocityBuilder.java
new file mode 100644
index 00000000..07d9e6a6
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/velocity/impl/VelocityBuilder.java
@@ -0,0 +1,59 @@
+package edu.asu.diging.gilesecosystem.web.velocity.impl;
+
+import java.io.StringWriter;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Service;
+
+import edu.asu.diging.gilesecosystem.web.velocity.IVelocityBuilder;
+
+@Service
+@PropertySource("classpath:/config.properties")
+public class VelocityBuilder implements IVelocityBuilder {
+
+ private VelocityEngine engine;
+
+ @Autowired
+ private Environment env;
+
+ @PostConstruct
+ public void init() throws Exception {
+ engine = new VelocityEngine();
+ engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+ engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+ engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
+ "org.apache.velocity.runtime.log.Log4JLogChute");
+ engine.setProperty("runtime.log.logsystem.log4j.logger", "velocity");
+ engine.init();
+ }
+
+ @Override
+ public String getRenderedTemplate(String templateName, Map contextProperties)
+ throws ResourceNotFoundException, ParseErrorException, Exception {
+ Template template = engine.getTemplate(templateName);
+ VelocityContext context = new VelocityContext();
+
+ for (String key : contextProperties.keySet()) {
+ context.put(key, contextProperties.get(key));
+ }
+
+ context.put("giles_url", env.getProperty("giles_url"));
+
+ StringWriter writer = new StringWriter();
+ template.merge(context, writer);
+ return writer.toString();
+ }
+
+}
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/zookeeper/INepomukServiceDiscoverer.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/zookeeper/INepomukServiceDiscoverer.java
new file mode 100644
index 00000000..6734506b
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/zookeeper/INepomukServiceDiscoverer.java
@@ -0,0 +1,9 @@
+package edu.asu.diging.gilesecosystem.web.zookeeper;
+
+import edu.asu.diging.gilesecosystem.web.exceptions.NoNepomukFoundException;
+
+public interface INepomukServiceDiscoverer {
+
+ String getRandomNepomukInstance() throws NoNepomukFoundException;
+
+}
\ No newline at end of file
diff --git a/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/zookeeper/impl/NepomukServiceDiscoverer.java b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/zookeeper/impl/NepomukServiceDiscoverer.java
new file mode 100644
index 00000000..b9bdcf48
--- /dev/null
+++ b/giles-eco/src/main/java/edu/asu/diging/gilesecosystem/web/zookeeper/impl/NepomukServiceDiscoverer.java
@@ -0,0 +1,126 @@
+package edu.asu.diging.gilesecosystem.web.zookeeper.impl;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryNTimes;
+import org.apache.curator.utils.ZKPaths;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
+
+import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
+import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
+import edu.asu.diging.gilesecosystem.web.exceptions.NoNepomukFoundException;
+import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
+import edu.asu.diging.gilesecosystem.web.zookeeper.INepomukServiceDiscoverer;
+
+@Service
+public class NepomukServiceDiscoverer implements INepomukServiceDiscoverer {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ private String znode;
+
+ private CuratorFramework curatorFramework;
+
+ @Autowired
+ private IPropertiesManager propertiesManager;
+
+ @Autowired
+ private ISystemMessageHandler msgHandler;
+
+ @PostConstruct
+ public void init() throws Exception {
+ curatorFramework = CuratorFrameworkFactory
+ .newClient(propertiesManager.getProperty(Properties.ZOOKEEPER_HOST)
+ + ":"
+ + propertiesManager.getProperty(Properties.ZOOKEEPER_PORT) , new RetryNTimes(5, 1000));
+ curatorFramework.start();
+
+ znode = "/services/" + propertiesManager.getProperty(Properties.ZOOKEEPER_NEPOMUK_SERVICE_NAME);
+ checkServices();
+ }
+
+ private void checkServices() throws Exception {
+ List uris = curatorFramework.getChildren().forPath(znode);
+ for (String uri : uris) {
+ logger.debug("Found: " + uri);
+ byte[] url = curatorFramework.getData().forPath(ZKPaths.makePath(znode, uri));
+ if (url != null) {
+ logger.debug("with URL: " + new String(url));
+ msgHandler.handleMessage("Nepomuk instance found.", "Giles found a Nepomuk instance at ZNode " + uri + " with URL " + new String(url), MessageType.INFO);
+ } else {
+ msgHandler.handleMessage("No Nepomuk URL configured.", "There was no Nepomuk instance found at " + new String(uri), MessageType.WARNING);
+ logger.debug("There was no URL registered with the ZNode.");
+ }
+ }
+ }
+
+ @Override
+ public String getRandomNepomukInstance() throws NoNepomukFoundException {
+ // throws Exception
+ List uris;
+ try {
+ uris = curatorFramework.getChildren().forPath(znode);
+ } catch (Exception e) {
+ throw new NoNepomukFoundException(e);
+ }
+ int randomInstance = ThreadLocalRandom.current().nextInt(0, uris.size());
+ for (int i = 0; i < uris.size(); i++) {
+ // get random Nepomuk instance
+ byte[] urlBytes;
+ try {
+ urlBytes = curatorFramework.getData().forPath(ZKPaths.makePath(znode, uris.get(randomInstance)));
+ } catch (Exception e) {
+ throw new NoNepomukFoundException(e);
+ }
+ if (urlBytes != null) {
+ String url = new String(urlBytes);
+ try {
+ if (validateUrl(url)) {
+ // if Nepomuk instance url specified and nepomuk responds with ok
+ // return url
+ return url;
+ }
+ } catch (IOException e) {
+ msgHandler.handleMessage("Nepomuk URL could not be validated.", e, MessageType.WARNING);
+ }
+ }
+
+ // if there is no URL or URL is not valid, let's take the next instance
+ randomInstance++;
+ // if we're at the end of the list, start from its beginning
+ if (randomInstance >= uris.size()) {
+ randomInstance -= uris.size();
+ }
+ }
+
+ return null;
+ }
+
+ private boolean validateUrl(String url) throws IOException {
+ URL myURL = new URL(url);
+ HttpURLConnection myConnection = (HttpURLConnection) myURL.openConnection();
+
+ try {
+ if (myConnection.getResponseCode()==HttpStatus.OK.value()) {
+ return true;
+ } else {
+ return false;
+ }
+ } finally {
+ myConnection.disconnect();
+ }
+ }
+}
diff --git a/giles-eco/src/main/resources/META-INF/hibernate/orm.xml b/giles-eco/src/main/resources/META-INF/hibernate/orm.xml
index d2d5a8ef..42828555 100644
--- a/giles-eco/src/main/resources/META-INF/hibernate/orm.xml
+++ b/giles-eco/src/main/resources/META-INF/hibernate/orm.xml
@@ -4,7 +4,7 @@
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
+
@@ -20,7 +20,7 @@
-
+
@@ -30,18 +30,18 @@
-
+
-
+
-
+
@@ -52,16 +52,16 @@
-
+
-
+
-
+
@@ -72,7 +72,7 @@
-
+
diff --git a/giles-eco/src/main/resources/config.properties b/giles-eco/src/main/resources/config.properties
index f1166eba..1f546d7d 100755
--- a/giles-eco/src/main/resources/config.properties
+++ b/giles-eco/src/main/resources/config.properties
@@ -11,6 +11,15 @@ hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
hibernate.show_sql=${hibernate.log.sql}
hibernate.format_sql=true
+# Zookeeper
+zookeeper_host=${zookeeper.host}
+zookeeper_port=${zookeeper.port}
+zookeeepr_service_nepomuk_name=nepomuk
+
+# Nepomuk
+nepomuk_ping_endpoint=/rest/ping
+nepomuk_files_endpoint=/rest/files/{0}
+
# Github
github_show_login=${github.show.login}
github_client_id=${github.clientId}
@@ -102,3 +111,7 @@ processor_prefix=processor_
processor_color_prefix=processor_color_
processor_freddie=Solr
processor_color_freddie=yellowgreen
+
+# Email notification
+email_enabled=${email.enabled}
+email_from=${email.from}
\ No newline at end of file
diff --git a/giles-eco/src/main/resources/locale/messages.properties b/giles-eco/src/main/resources/locale/messages.properties
index 6d84d4a8..b58233da 100755
--- a/giles-eco/src/main/resources/locale/messages.properties
+++ b/giles-eco/src/main/resources/locale/messages.properties
@@ -33,3 +33,6 @@ admin_user_new_password_mismatch= New password and retyped password must match.
admin_user_change_password_success=You have successfully changed the password of user {0}.
admin_user_change_password_failure=There was an error. Password could not be changed.
admin_user_change_password_not_allowed=Sorry, this action is not allowed.
+
+email.account_created.subject = A new account has been created in Giles!
+email.tail = \n\n------------------------------------------------------------------------------------------------------------\nThis message was sent from Giles. Please don't reply to this message; it's automated and not monitored for responses.
\ No newline at end of file
diff --git a/giles-eco/src/main/resources/velocitytemplates/email/newAccount.vm b/giles-eco/src/main/resources/velocitytemplates/email/newAccount.vm
new file mode 100644
index 00000000..c8c24b6d
--- /dev/null
+++ b/giles-eco/src/main/resources/velocitytemplates/email/newAccount.vm
@@ -0,0 +1,7 @@
+Hi $admin:
+
+A new account for $createdUser ($createdUsername) has been created in Giles. Please review the account and approve or reject it here:
+$giles_url/users
+
+Your Giles Team
+
diff --git a/giles-eco/src/main/webapp/WEB-INF/spring/email-config.xml b/giles-eco/src/main/webapp/WEB-INF/spring/email-config.xml
new file mode 100644
index 00000000..85f613bb
--- /dev/null
+++ b/giles-eco/src/main/webapp/WEB-INF/spring/email-config.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+ smtp
+ true
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/giles-eco/src/main/webapp/WEB-INF/spring/root-context.xml b/giles-eco/src/main/webapp/WEB-INF/spring/root-context.xml
index df0f713f..0a5bd501 100755
--- a/giles-eco/src/main/webapp/WEB-INF/spring/root-context.xml
+++ b/giles-eco/src/main/webapp/WEB-INF/spring/root-context.xml
@@ -19,6 +19,9 @@
+
+
+
diff --git a/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/nepomuk/impl/NepomukUrlServiceTest.java b/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/nepomuk/impl/NepomukUrlServiceTest.java
new file mode 100644
index 00000000..fd4126ff
--- /dev/null
+++ b/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/nepomuk/impl/NepomukUrlServiceTest.java
@@ -0,0 +1,69 @@
+package edu.asu.diging.gilesecosystem.web.nepomuk.impl;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
+import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
+import edu.asu.diging.gilesecosystem.web.domain.IFile;
+import edu.asu.diging.gilesecosystem.web.domain.impl.File;
+import edu.asu.diging.gilesecosystem.web.exceptions.NoNepomukFoundException;
+import edu.asu.diging.gilesecosystem.web.nepomuk.INepomukUrlService;
+import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
+import edu.asu.diging.gilesecosystem.web.zookeeper.INepomukServiceDiscoverer;
+
+public class NepomukUrlServiceTest {
+
+ @Mock
+ protected INepomukServiceDiscoverer nepomukDiscoverer;
+
+ @Mock
+ protected IPropertiesManager propertyManager;
+
+ @Mock
+ private ISystemMessageHandler messageHandler;
+
+ @InjectMocks
+ private INepomukUrlService serviceToTest;
+
+ private final String NEPOMUK_URL = "http://nepomuk/";
+ private final String FILES_ENDPOINT = "/rest/files/";
+ private final String ENDPOINT_PLACEHOLDER = "{0}";
+
+ @Before
+ public void setUp() throws NoNepomukFoundException {
+ serviceToTest = new NepomukUrlService();
+ MockitoAnnotations.initMocks(this);
+
+ Mockito.when(nepomukDiscoverer.getRandomNepomukInstance()).thenReturn(NEPOMUK_URL);
+ Mockito.when(propertyManager.getProperty(Properties.NEPOMUK_FILES_ENDPOINT)).thenReturn(FILES_ENDPOINT + ENDPOINT_PLACEHOLDER);
+
+ }
+
+ @Test
+ public void test_getFileDownloadPath_success() {
+ IFile file = new File();
+ String ID = "ID";
+ file.setStorageId(ID);
+
+ String url = serviceToTest.getFileDownloadPath(file);
+ Assert.assertEquals(NEPOMUK_URL + FILES_ENDPOINT + ID, url);
+ }
+
+ @Test
+ public void test_getFileDownloadPath_exception() throws NoNepomukFoundException {
+ Mockito.when(nepomukDiscoverer.getRandomNepomukInstance()).thenThrow(new NoNepomukFoundException());
+
+ IFile file = new File();
+ String ID = "ID";
+ file.setStorageId(ID);
+
+ String url = serviceToTest.getFileDownloadPath(file);
+ Assert.assertNull(url);
+ }
+}
diff --git a/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/tokens/impl/IntrospectTokenServiceTest.java b/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/tokens/impl/IntrospectTokenServiceTest.java
index c5b1d9e6..3e5fbb93 100644
--- a/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/tokens/impl/IntrospectTokenServiceTest.java
+++ b/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/tokens/impl/IntrospectTokenServiceTest.java
@@ -11,7 +11,6 @@
import org.springframework.web.client.RestTemplate;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
-import edu.asu.diging.gilesecosystem.web.config.GilesTokenConfig;
import edu.asu.diging.gilesecosystem.web.exceptions.AppMisconfigurationException;
import edu.asu.diging.gilesecosystem.web.exceptions.ServerMisconfigurationException;
import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
diff --git a/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/tokens/impl/TokenServiceTest.java b/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/tokens/impl/TokenServiceTest.java
index 208b3f72..eccaa9de 100644
--- a/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/tokens/impl/TokenServiceTest.java
+++ b/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/tokens/impl/TokenServiceTest.java
@@ -18,6 +18,7 @@
import org.mockito.MockitoAnnotations;
import org.springframework.social.google.api.drive.DriveApp.AppIcon;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.web.apps.impl.RegisteredApp;
@@ -30,7 +31,8 @@ public class TokenServiceTest {
@Mock
private IPropertiesManager propertiesManager;
-
+ @Mock
+ private ISystemMessageHandler messageHandler;
@InjectMocks
private TokenService serviceToTest;
diff --git a/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/users/impl/AdminUserDetailsServiceTest.java b/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/users/impl/AdminUserDetailsServiceTest.java
index 49c9858c..9f89c30c 100644
--- a/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/users/impl/AdminUserDetailsServiceTest.java
+++ b/giles-eco/src/test/java/edu/asu/diging/gilesecosystem/web/users/impl/AdminUserDetailsServiceTest.java
@@ -26,6 +26,7 @@
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.util.PropertiesPersister;
+import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.users.GilesGrantedAuthority;
public class AdminUserDetailsServiceTest {
@@ -36,7 +37,8 @@ public class AdminUserDetailsServiceTest {
private Properties users;
@Mock
private PathResource customPropsResource;
-
+ @Mock
+ private ISystemMessageHandler messageHandler;
@InjectMocks
private AdminUserDetailsService adminDetailsServiceToTest;