From f5f01f154274bb3c30708850d6d19399b1c38117 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Mon, 29 Mar 2010 20:13:45 +0000 Subject: [PATCH] CSPACE-1334: Meaningful error message is now logged if an authority property in tenant bindings is invalid. --- .../java/RemoteDocumentModelHandlerImpl.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java index 452737406..4f660b263 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java @@ -45,6 +45,7 @@ import org.collectionspace.services.common.vocabulary.RefNameUtils; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.nuxeo.ecm.core.api.DocumentModel; +import org.nuxeo.ecm.core.api.model.PropertyException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -204,8 +205,8 @@ public abstract class RemoteDocumentModelHandlerImpl } public AuthorityRefList getAuthorityRefs( - DocumentWrapper docWrapper, - List authRefFields) { + DocumentWrapper docWrapper, + List authRefFields) throws PropertyException { AuthorityRefList authRefList = new AuthorityRefList(); try { DocumentModel docModel = docWrapper.getWrappedObject(); @@ -213,32 +214,39 @@ public abstract class RemoteDocumentModelHandlerImpl authRefList.getAuthorityRefItem(); for(String field:authRefFields){ - String refName = (String)docModel.getPropertyValue(field); - if(refName==null) - continue; + String refName = (String)docModel.getPropertyValue(field); + if(refName==null) + continue; try{ - RefNameUtils.AuthorityTermInfo termInfo = - RefNameUtils.parseAuthorityTermInfo(refName); - AuthorityRefList.AuthorityRefItem ilistItem = - new AuthorityRefList.AuthorityRefItem(); - ilistItem.setRefName(refName); - ilistItem.setAuthDisplayName(termInfo.inAuthority.displayName); - ilistItem.setItemDisplayName(termInfo.displayName); - ilistItem.setSourceField(field); - ilistItem.setUri(termInfo.getRelativeUri()); + RefNameUtils.AuthorityTermInfo termInfo = + RefNameUtils.parseAuthorityTermInfo(refName); + AuthorityRefList.AuthorityRefItem ilistItem = + new AuthorityRefList.AuthorityRefItem(); + ilistItem.setRefName(refName); + ilistItem.setAuthDisplayName(termInfo.inAuthority.displayName); + ilistItem.setItemDisplayName(termInfo.displayName); + ilistItem.setSourceField(field); + ilistItem.setUri(termInfo.getRelativeUri()); list.add(ilistItem); } catch( Exception e ) { + // FIXME: Do we need to throw this Exception here? if (logger.isDebugEnabled()) { logger.debug("Caught exception in getAuthorityRefs", e); } } } + } catch (PropertyException pe) { + String msg = + "Attempted to retrieve value for invalid or missing authority field. " + + "Check authority field properties in tenant bindings."; + logger.warn(msg, pe); + throw pe; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Caught exception in getAuthorityRefs", e); } Response response = Response.status( - Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build(); + Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to retrieve authority references").type("text/plain").build(); throw new WebApplicationException(response); } return authRefList; -- 2.47.3