changeset 82:c000b4b386bc

better "internal error" message. fix NPE when codex has no identifier.
author casties
date Wed, 21 Sep 2016 19:53:15 +0200
parents 0d5d36c83e77
children e07e9f5afaa3
files src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CodexEditorTemplate.java
diffstat 2 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractBean.java	Mon Aug 29 20:18:04 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractBean.java	Wed Sep 21 19:53:15 2016 +0200
@@ -44,9 +44,11 @@
 	
 	protected void printInternalError(Exception e){
 		addErrorMsg("Internal Error, this action could not be executed correctly.");
-		addErrorMsg(e.getMessage());
+		addErrorMsg("Error:");
+		addErrorMsg(e.toString());
+		addErrorMsg(e.getStackTrace()[0].toString());
 		addErrorMsg("Server time: " + DateFormat.getDateTimeInstance().format(new Date()));
-		addErrorMsg("Please inform support: jurzua@mpiwg-berlin.mpg.de");
+		addErrorMsg("Please inform support: casties@mpiwg-berlin.mpg.de");
 	}
 	
 	protected SessionBean getSessionBean() {
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CodexEditorTemplate.java	Mon Aug 29 20:18:04 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CodexEditorTemplate.java	Wed Sep 21 19:53:15 2016 +0200
@@ -427,7 +427,7 @@
 		boolean consistent = false;
 		
 		Entity country = this.getCountryLo().entity;
-		if(country != null && country.isPersistent() && StringUtils.isNotEmpty(getCountryLo().getAttribute().getValue())){
+		if(country != null && country.isPersistent() &&  getCountryLo().getAttribute() != null &&StringUtils.isNotEmpty(getCountryLo().getAttribute().getValue())){
 			
 			Attribute att = getWrapper().getAttributeByName(country.getId(), "name");
 			
@@ -452,7 +452,7 @@
 		boolean consistent = false;
 		
 		Entity city = this.getCityLo().entity;
-		if(city != null && city.isPersistent() && StringUtils.isNotEmpty(getCityLo().getAttribute().getValue())){
+		if(city != null && city.isPersistent() &&  getCityLo().getAttribute() != null &&StringUtils.isNotEmpty(getCityLo().getAttribute().getValue())){
 			
 			List<Entity> list = getWrapper().getTargetsForSourceRelation(city, is_part_of, PLACE, 1);
 			
@@ -477,7 +477,7 @@
 		boolean consistent = false;
 		
 		Entity repository = this.getRepositoryLo().entity;
-		if(repository != null && repository.isPersistent() && StringUtils.isNotEmpty(getRepositoryLo().getAttribute().getValue())){
+		if(repository != null && repository.isPersistent() &&  getCollectionLo().getAttribute() != null && StringUtils.isNotEmpty(getRepositoryLo().getAttribute().getValue())){
 			//juc List<Entity> list = getSearchServ().getTargetsForSourceRelation(repository, is_in, PLACE, 1);
 			List<Entity> list = getWrapper().getTargetsForSourceRelation(repository, is_in, PLACE, 1);
 			
@@ -502,7 +502,7 @@
 		boolean consistent = false;
 		
 		Entity collection = this.getCollectionLo().entity;
-		if(collection != null && collection.isPersistent() && StringUtils.isNotEmpty(getCollectionLo().getAttribute().getValue())){
+		if(collection != null && collection.isPersistent() && getCollectionLo().getAttribute() != null && StringUtils.isNotEmpty(getCollectionLo().getAttribute().getValue())){
 			
 			List<Entity> list = getWrapper().getTargetsForSourceRelation(collection, is_part_of, REPOSITORY, 1);
 			
@@ -526,7 +526,7 @@
 	private void checkConsistencyOfCodex(Entity collection){
 		
 		Entity codex = this.getCodexLo().entity;
-		if(codex != null && codex.isPersistent() && StringUtils.isNotEmpty(getCodexLo().getAttribute().getValue())){
+		if(codex != null && codex.isPersistent() && getCodexLo().getAttribute() != null && StringUtils.isNotEmpty(getCodexLo().getAttribute().getValue())){
 			
 			Attribute identifier = getWrapper().getAttributeByName(codex.getId(), "identifier");
 			
@@ -558,7 +558,7 @@
 		
 		if(bCodex){
 			Entity codex = this.getCodexLo().entity;
-			if(codex != null && codex.isPersistent() && StringUtils.isNotEmpty(getCodexLo().getAttribute().getValue()))
+			if(codex != null && codex.isPersistent() && getCodexLo().getAttribute() != null && StringUtils.isNotEmpty(getCodexLo().getAttribute().getValue()))
 				this.getCodexLo().statusImage.setStatus(StatusImage.STATUS_FALSE);
 			else
 				this.getCodexLo().statusImage.setStatus(StatusImage.STATUS_UNSET);
@@ -566,7 +566,7 @@
 		
 		if(bCollection){
 			Entity collection = this.getCollectionLo().entity;
-			if(collection != null && collection.isPersistent() && StringUtils.isNotEmpty(this.getCollectionLo().getAttribute().getValue()))
+			if(collection != null && collection.isPersistent() && this.getCollectionLo().getAttribute() != null && StringUtils.isNotEmpty(this.getCollectionLo().getAttribute().getValue()))
 				this.getCollectionLo().statusImage.setStatus(StatusImage.STATUS_FALSE);
 			else
 				this.getCollectionLo().statusImage.setStatus(StatusImage.STATUS_UNSET);
@@ -574,7 +574,7 @@
 		
 		if(bRepository){
 			Entity repository = this.getRepositoryLo().entity;
-			if(repository != null && repository.isPersistent() && StringUtils.isNotEmpty(this.getRepositoryLo().getAttribute().getValue()))
+			if(repository != null && repository.isPersistent() && this.getRepositoryLo().getAttribute() != null && StringUtils.isNotEmpty(this.getRepositoryLo().getAttribute().getValue()))
 				this.getRepositoryLo().statusImage.setStatus(StatusImage.STATUS_FALSE);
 			else
 				this.getRepositoryLo().statusImage.setStatus(StatusImage.STATUS_UNSET);
@@ -582,7 +582,7 @@
 		
 		if(bCity){
 			Entity city = this.getCityLo().entity;
-			if(city != null && city.isPersistent() && StringUtils.isNotEmpty(this.getCityLo().getAttribute().getValue()))
+			if(city != null && city.isPersistent() && this.getCityLo().getAttribute() != null && StringUtils.isNotEmpty(this.getCityLo().getAttribute().getValue()))
 				this.getCityLo().statusImage.setStatus(StatusImage.STATUS_FALSE);
 			else
 				this.getCityLo().statusImage.setStatus(StatusImage.STATUS_UNSET);
@@ -590,7 +590,7 @@
 		
 		if(bCountry){
 			Entity country = this.getCountryLo().entity;
-			if(country != null && country.isPersistent() && StringUtils.isNotEmpty(this.getCountryLo().getAttribute().getValue()))
+			if(country != null && country.isPersistent() && this.getCountryLo().getAttribute() != null && StringUtils.isNotEmpty(this.getCountryLo().getAttribute().getValue()))
 				this.getCountryLo().statusImage.setStatus(StatusImage.STATUS_FALSE);
 			else
 				this.getCountryLo().statusImage.setStatus(StatusImage.STATUS_UNSET);