diff --git a/nepomuk/.classpath b/nepomuk/.classpath
index 08532bc..26981b6 100644
--- a/nepomuk/.classpath
+++ b/nepomuk/.classpath
@@ -23,11 +23,6 @@
-
-
-
-
-
diff --git a/nepomuk/.gitignore b/nepomuk/.gitignore
index cc9da8f..a3a7f0f 100644
--- a/nepomuk/.gitignore
+++ b/nepomuk/.gitignore
@@ -1,3 +1,4 @@
/.settings/
/target/
/target/
+/buildNumber.properties
diff --git a/nepomuk/pom.xml b/nepomuk/pom.xml
index b9d92c8..5c7476b 100644
--- a/nepomuk/pom.xml
+++ b/nepomuk/pom.xml
@@ -13,8 +13,9 @@
1.7.5
4.3.1.RELEASE
4.1.3.RELEASE
- 0.2.1-SNAPSHOT
- 0.4.1
+ 0.5
+ 0.4.2
+
$2a$04$NXKVTx9XrpEST6CLn/ps7eP8YsK3t.5A/mvAoYpg.X8QqgOKtc1za
http://localhost:8082/nepomuk/
@@ -393,6 +394,61 @@
/${tomcat.app}
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ org.codehaus.mojo
+ buildnumber-maven-plugin
+ [0,)
+
+ create
+
+
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ buildnumber-maven-plugin
+ 1.4
+
+
+ validate
+
+ create
+
+
+
+
+ false
+ false
+
+
+ - buildNumber\d*
+ - timestamp
+
+ ${geco.nepomuk.version}-{0} ({1,date,yyyy-MM-dd HH:mm:ss})
+
+
+
+
+ scm:svn:http://none
+ scm:svn:https://none
+
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/domain/IFile.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/domain/IFile.java
index 8bd27da..131281d 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/domain/IFile.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/domain/IFile.java
@@ -49,4 +49,8 @@ public interface IFile extends IStorableObject {
public abstract String getContentType();
+ public abstract void setGilesFileId(String gilesFileId);
+
+ public abstract String getGilesFileId();
+
}
\ No newline at end of file
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/domain/impl/File.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/domain/impl/File.java
index 19a9d6d..8b48e24 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/domain/impl/File.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/domain/impl/File.java
@@ -1,5 +1,6 @@
package edu.asu.diging.gilesecosystem.nepomuk.core.domain.impl;
+import javax.jdo.annotations.Index;
import javax.persistence.Entity;
import javax.persistence.Id;
@@ -9,19 +10,19 @@
@Entity
public class File implements IFile {
- private String uploadId;
- private String filename;
- private String username;
- private String documentId;
- @Id
- private String id;
+ @Index private String uploadId;
+ @Index private String filename;
+ @Index private String username;
+ @Index private String documentId;
+ @Id @Index private String id;
private String uploadDate;
private String processedDate;
private long size;
private String filepath;
private FileType fileType;
private String contentType;
-
+ @Index private String gilesFileId;
+
public File() {
}
@@ -181,5 +182,15 @@ public String getContentType() {
public void setContentType(String contentType) {
this.contentType = contentType;
}
+
+ @Override
+ public String getGilesFileId() {
+ return gilesFileId;
+ }
+
+ @Override
+ public void setGilesFileId(String gilesFileId) {
+ this.gilesFileId = gilesFileId;
+ }
}
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/exception/NoUniqueResultException.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/exception/NoUniqueResultException.java
new file mode 100644
index 0000000..d59e140
--- /dev/null
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/exception/NoUniqueResultException.java
@@ -0,0 +1,36 @@
+package edu.asu.diging.gilesecosystem.nepomuk.core.exception;
+
+public class NoUniqueResultException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3769968277605578574L;
+
+ public NoUniqueResultException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public NoUniqueResultException(String message, Throwable cause,
+ boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ // TODO Auto-generated constructor stub
+ }
+
+ public NoUniqueResultException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public NoUniqueResultException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public NoUniqueResultException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/IFilesDatabaseClient.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/IFilesDatabaseClient.java
index 6e014c9..a497bda 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/IFilesDatabaseClient.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/IFilesDatabaseClient.java
@@ -2,7 +2,11 @@
import java.util.List;
+import javax.persistence.TypedQuery;
+
import edu.asu.diging.gilesecosystem.nepomuk.core.domain.IFile;
+import edu.asu.diging.gilesecosystem.nepomuk.core.domain.impl.File;
+import edu.asu.diging.gilesecosystem.nepomuk.core.exception.NoUniqueResultException;
import edu.asu.diging.gilesecosystem.nepomuk.core.exception.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.nepomuk.core.store.IDatabaseClient;
@@ -20,4 +24,7 @@ public interface IFilesDatabaseClient extends IDatabaseClient {
public List getFilesByProperty(String propName, String propValue);
+ public abstract IFile getFile(String uploadId, String documentId, String filename)
+ throws NoUniqueResultException;
+
}
\ No newline at end of file
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/IFilesManager.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/IFilesManager.java
index c9fd50b..1974cbe 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/IFilesManager.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/IFilesManager.java
@@ -3,6 +3,7 @@
import java.util.List;
import edu.asu.diging.gilesecosystem.nepomuk.core.domain.IFile;
+import edu.asu.diging.gilesecosystem.nepomuk.core.exception.NoUniqueResultException;
import edu.asu.diging.gilesecosystem.nepomuk.core.exception.UnstorableObjectException;
public interface IFilesManager {
@@ -29,4 +30,7 @@ public interface IFilesManager {
public abstract String getRelativePathOfFile(IFile file);
public abstract byte[] getFileContent(IFile file);
+
+ public abstract IFile getFile(String uploadId, String documentId, String filename)
+ throws NoUniqueResultException;
}
\ No newline at end of file
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesDatabaseClient.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesDatabaseClient.java
index 95e32dd..e9281ca 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesDatabaseClient.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesDatabaseClient.java
@@ -6,12 +6,14 @@
import javax.annotation.PreDestroy;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import edu.asu.diging.gilesecosystem.nepomuk.core.domain.IFile;
import edu.asu.diging.gilesecosystem.nepomuk.core.domain.impl.File;
+import edu.asu.diging.gilesecosystem.nepomuk.core.exception.NoUniqueResultException;
import edu.asu.diging.gilesecosystem.nepomuk.core.exception.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.nepomuk.core.files.IFilesDatabaseClient;
import edu.asu.diging.gilesecosystem.nepomuk.core.store.objectdb.DatabaseClient;
@@ -74,6 +76,21 @@ public IFile getFile(String filename) {
}
return files.get(0);
}
+
+ @Override
+ public IFile getFile(String uploadId, String documentId, String filename) throws NoUniqueResultException {
+ String query = "SELECT t FROM " + File.class.getName() + " t WHERE t.uploadId = '" + uploadId + "' and t.documentId = '" + documentId + "' and t.filename = '" + filename + "'";
+ TypedQuery docs = em.createQuery(query, File.class);
+
+ List results = docs.getResultList();
+ if (results.size() > 1) {
+ throw new NoUniqueResultException("There are more than one result for file: " + uploadId + ", " + documentId + ", " + filename);
+ }
+ if (results.isEmpty()) {
+ return null;
+ }
+ return results.get(0);
+ }
@Override
protected String getIdPrefix() {
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesManager.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesManager.java
index 1de56a8..8ddb941 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesManager.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesManager.java
@@ -9,6 +9,7 @@
import org.springframework.stereotype.Service;
import edu.asu.diging.gilesecosystem.nepomuk.core.domain.IFile;
+import edu.asu.diging.gilesecosystem.nepomuk.core.exception.NoUniqueResultException;
import edu.asu.diging.gilesecosystem.nepomuk.core.exception.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.nepomuk.core.files.IFilesDatabaseClient;
import edu.asu.diging.gilesecosystem.nepomuk.core.files.IFilesManager;
@@ -71,7 +72,11 @@ public IFile saveFile(IFile file) throws UnstorableObjectException {
return file;
}
-
+ @Override
+ public IFile getFile(String uploadId, String documentId, String filename) throws NoUniqueResultException {
+ return databaseClient.getFile(uploadId, documentId, filename);
+ }
+
@Override
public String getRelativePathOfFile(IFile file) {
IFileTypeHandler handler = fileHandlerRegistry.getHandler(file
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/kafka/impl/StorageRequestReceiver.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/kafka/impl/StorageRequestReceiver.java
index 435ff11..29fdabe 100644
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/kafka/impl/StorageRequestReceiver.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/kafka/impl/StorageRequestReceiver.java
@@ -11,6 +11,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.asu.diging.gilesecosystem.nepomuk.core.service.IRequestProcessor;
+import edu.asu.diging.gilesecosystem.nepomuk.core.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.requests.IStorageRequest;
import edu.asu.diging.gilesecosystem.requests.impl.StorageRequest;
@@ -25,6 +26,9 @@ public class StorageRequestReceiver {
@Autowired
private IPropertiesManager propertiesManager;
+
+ @Autowired
+ private ISystemMessageHandler systemMessageHandler;
@KafkaListener(topics = "${topic_storage_request}")
public void receiveMessage(String message) {
@@ -34,6 +38,7 @@ public void receiveMessage(String message) {
request = mapper.readValue(message, StorageRequest.class);
} catch (IOException e) {
logger.error("Could not unmarshall request.", e);
+ systemMessageHandler.handleError("Could not unmarshall request.", e);
// FIXME: handel this case
return;
}
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/apps/impl/RegisteredAppsManager.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/apps/impl/RegisteredAppsManager.java
index c7c8b62..85d9797 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/apps/impl/RegisteredAppsManager.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/apps/impl/RegisteredAppsManager.java
@@ -12,6 +12,7 @@
import edu.asu.diging.gilesecosystem.nepomuk.core.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.nepomuk.core.apps.IRegisteredAppDatabaseClient;
+import edu.asu.diging.gilesecosystem.nepomuk.core.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.nepomuk.core.service.apps.IRegisteredAppManager;
import edu.asu.diging.gilesecosystem.nepomuk.core.exception.TokenGenerationErrorException;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
@@ -30,6 +31,9 @@ public class RegisteredAppsManager implements IRegisteredAppManager {
@Autowired
private ITokenService tokenService;
+ @Autowired
+ private ISystemMessageHandler systemMessageHandler;
+
@Override
public IRegisteredApp storeApp(IRegisteredApp app) {
@@ -40,6 +44,7 @@ public IRegisteredApp storeApp(IRegisteredApp app) {
databaseClient.store(app);
} catch (UnstorableObjectException e) {
logger.error("Could not store app.", e);
+ systemMessageHandler.handleError("Could not store app.", e);
return null;
}
return app;
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/handlers/AbstractFileHandler.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/handlers/AbstractFileHandler.java
index ec0c08d..4161206 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/handlers/AbstractFileHandler.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/handlers/AbstractFileHandler.java
@@ -19,13 +19,17 @@
import edu.asu.diging.gilesecosystem.nepomuk.core.files.IFileStorageManager;
import edu.asu.diging.gilesecosystem.nepomuk.core.files.IFilesManager;
import edu.asu.diging.gilesecosystem.nepomuk.core.service.IFileTypeHandler;
+import edu.asu.diging.gilesecosystem.nepomuk.core.service.ISystemMessageHandler;
public abstract class AbstractFileHandler implements IFileTypeHandler {
private Logger logger = LoggerFactory.getLogger(getClass());
-
+
@Autowired
private IFilesManager filesManager;
+
+ @Autowired
+ private ISystemMessageHandler systemMessageHandler;
protected byte[] getFileContentFromUrl(URL url) throws IOException {
URLConnection con = url.openConnection();
@@ -58,12 +62,17 @@ public byte[] getFileContent(IFile file) {
try {
return getFileContentFromUrl(fileObject.toURI().toURL());
} catch (IOException e) {
+ systemMessageHandler.handleError("Could not read file.", e);
logger.error("Could not read file.", e);
return null;
}
}
public IFile processFile(IFile file, byte[] content) throws NepomukFileStorageException {
+ if (content == null) {
+ logger.warn("File " + file.getGilesFileId() + " does not have any content.");
+ return null;
+ }
Tika tika = new Tika();
String contentType = tika.detect(content);
@@ -76,6 +85,7 @@ public IFile processFile(IFile file, byte[] content) throws NepomukFileStorageEx
filesManager.saveFile(file);
} catch (UnstorableObjectException e) {
logger.error("Could not store file.", e);
+ systemMessageHandler.handleError("Could not store file.", e);
return null;
}
return file;
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/impl/RequestProcessor.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/impl/RequestProcessor.java
index 5d6258e..1ffd148 100644
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/impl/RequestProcessor.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/impl/RequestProcessor.java
@@ -81,6 +81,7 @@ public void processRequest(IStorageRequest request) {
newFile.setUsername(request.getUsername());
newFile.setFilename(request.getFilename());
newFile.setFileType(request.getFileType());
+ newFile.setGilesFileId(request.getFileId());
byte[] content = downloadFile(request.getDownloadUrl());
try {
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/impl/SystemMessageHandler.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/impl/SystemMessageHandler.java
index 24323c0..6f6212d 100644
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/impl/SystemMessageHandler.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/core/service/impl/SystemMessageHandler.java
@@ -39,7 +39,7 @@ public class SystemMessageHandler implements ISystemMessageHandler {
public void setup() {
requestFactory.config(SystemMessageRequest.class);
}
-
+
/* (non-Javadoc)
* @see edu.asu.diging.gilesecosystem.nepomuk.core.service.impl.ISystemMessageHandler#handleError(java.lang.Exception)
*/
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/rest/FilesController.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/rest/FilesController.java
index bfb30ef..2147031 100644
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/rest/FilesController.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/rest/FilesController.java
@@ -15,16 +15,26 @@
import org.springframework.web.bind.annotation.RestController;
import edu.asu.diging.gilesecosystem.nepomuk.core.domain.IFile;
+import edu.asu.diging.gilesecosystem.nepomuk.core.exception.NoUniqueResultException;
import edu.asu.diging.gilesecosystem.nepomuk.core.files.IFilesManager;
+import edu.asu.diging.gilesecosystem.nepomuk.core.service.ISystemMessageHandler;
@RestController
public class FilesController {
private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ private ISystemMessageHandler systemMessageHandler;
public final static String FILE_ID_PLACEHOLDER = "{fileId}";
public final static String GET_FILE_URL = "/files/" + FILE_ID_PLACEHOLDER;
+ public final static String UPLOAD_ID_PLACEHOLDER = "{uploadId}";
+ public final static String DOCUMENT_ID_PLACEHOLDER = "{documentId}";
+ public final static String FILENAME_PLACEHOLDER = "{filename:.+?}";
+ public final static String GET_FILE_BY_FILENAME = "/files/" + UPLOAD_ID_PLACEHOLDER + "/" + DOCUMENT_ID_PLACEHOLDER + "/" + FILENAME_PLACEHOLDER;
+
@Autowired
private IFilesManager filesManager;
@@ -37,6 +47,37 @@ public ResponseEntity getFile(@PathVariable String fileId, HttpServletRe
return new ResponseEntity(HttpStatus.NOT_FOUND);
}
+ byte[] content = filesManager.getFileContent(file);
+ response.setContentType(file.getContentType());
+ response.setContentLength(content.length);
+ response.setHeader("Content-disposition", "filename=\"" + file.getFilename() + "\"");
+ try {
+ response.getOutputStream().write(content);
+ response.getOutputStream().close();
+ } catch (IOException e) {
+ logger.error("Could not write to output stream.", e);
+ systemMessageHandler.handleError("Could not write to output stream.", e);
+ return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+ @RequestMapping(value = GET_FILE_BY_FILENAME)
+ public ResponseEntity getFileByFilename(@PathVariable String uploadId, @PathVariable String documentId, @PathVariable String filename, HttpServletResponse response,
+ HttpServletRequest request) {
+ IFile file;
+ try {
+ file = filesManager.getFile(uploadId, documentId, filename);
+ } catch (NoUniqueResultException e) {
+ logger.error("Could not retrieve file.", e);
+ return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ if (file == null) {
+ return new ResponseEntity(HttpStatus.NOT_FOUND);
+ }
+
byte[] content = filesManager.getFileContent(file);
response.setContentType(file.getContentType());
response.setContentLength(content.length);
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/AddRegisteredAppController.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/AddRegisteredAppController.java
index d2b8f66..c8dc879 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/AddRegisteredAppController.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/AddRegisteredAppController.java
@@ -16,6 +16,7 @@
import edu.asu.diging.gilesecosystem.nepomuk.core.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.nepomuk.core.apps.impl.RegisteredApp;
+import edu.asu.diging.gilesecosystem.nepomuk.core.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.nepomuk.core.service.apps.IRegisteredAppManager;
import edu.asu.diging.gilesecosystem.nepomuk.core.validators.RegisteredAppValidator;
import edu.asu.diging.gilesecosystem.nepomuk.core.exception.TokenGenerationErrorException;
@@ -28,6 +29,9 @@ public class AddRegisteredAppController {
@Autowired
private IRegisteredAppManager appManager;
+
+ @Autowired
+ private ISystemMessageHandler systemMessageHandler;
@InitBinder("app")
public void init(WebDataBinder binder) {
@@ -54,6 +58,7 @@ public String registerApp(@Validated @ModelAttribute("app") RegisteredApp app, B
token = appManager.createToken(newApp);
} catch (TokenGenerationErrorException e) {
logger.error("Token generation failed.", e);
+ systemMessageHandler.handleError("Token generation failed.", e);
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/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/AdminPasswordController.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/AdminPasswordController.java
index 6d83a8b..122dafd 100644
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/AdminPasswordController.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/AdminPasswordController.java
@@ -18,6 +18,7 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+import edu.asu.diging.gilesecosystem.nepomuk.core.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.nepomuk.web.pages.AdminPassword;
import edu.asu.diging.gilesecosystem.nepomuk.web.validators.AdminPasswordValidator;
import edu.asu.diging.gilesecosystem.util.exceptions.BadPasswordException;
@@ -39,6 +40,9 @@ public class AdminPasswordController {
@Autowired
private IAdminUserManager adminManager;
+ @Autowired
+ private ISystemMessageHandler systemMessageHandler;
+
@InitBinder
public void init(WebDataBinder binder) {
binder.addValidators(validator);
@@ -86,6 +90,7 @@ public String changePassword(
// this should never happen because it should be caught by the
// validator
logger.error("Could not update password.", e);
+ systemMessageHandler.handleError("Could not update password.", e);
}
if (success) {
diff --git a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/EditPropertiesController.java b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/EditPropertiesController.java
index b1a9341..756e7aa 100755
--- a/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/EditPropertiesController.java
+++ b/nepomuk/src/main/java/edu/asu/diging/gilesecosystem/nepomuk/web/controller/admin/EditPropertiesController.java
@@ -18,6 +18,7 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+import edu.asu.diging.gilesecosystem.nepomuk.core.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.nepomuk.core.service.properties.Properties;
import edu.asu.diging.gilesecosystem.util.exceptions.PropertiesStorageException;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
@@ -29,6 +30,9 @@ public class EditPropertiesController {
@Autowired
private IPropertiesManager propertyManager;
+
+ @Autowired
+ private ISystemMessageHandler systemMessageHandler;
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder, WebDataBinder validateBinder) {
@@ -64,6 +68,7 @@ public String storeSystemConfig(@Validated @ModelAttribute SystemConfigPage syst
try {
propertyManager.updateProperties(propertiesMap);
} catch (PropertiesStorageException e) {
+ systemMessageHandler.handleError("An unexpected error occurred. System Configuration could not be saved.", e);
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/nepomuk/src/test/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesDatabaseClientTest.java b/nepomuk/src/test/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesDatabaseClientTest.java
index 38a96be..1a0086a 100644
--- a/nepomuk/src/test/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesDatabaseClientTest.java
+++ b/nepomuk/src/test/java/edu/asu/diging/gilesecosystem/nepomuk/core/files/impl/FilesDatabaseClientTest.java
@@ -19,6 +19,7 @@
import edu.asu.diging.gilesecosystem.nepomuk.core.domain.IFile;
import edu.asu.diging.gilesecosystem.nepomuk.core.domain.impl.File;
import edu.asu.diging.gilesecosystem.nepomuk.core.exception.UnstorableObjectException;
+import edu.asu.diging.gilesecosystem.nepomuk.core.files.IFilesDatabaseClient;
public class FilesDatabaseClientTest {
@@ -29,7 +30,7 @@ public class FilesDatabaseClientTest {
private TypedQuery typedQuery;
@InjectMocks
- private FilesDatabaseClient clientToTest;
+ private IFilesDatabaseClient clientToTest;
private final String ID = "id";
private final String ID2 = "id2";