From 2df6e8f4034b87d7c9b744bee08754fa727786c0 Mon Sep 17 00:00:00 2001 From: rkv Date: Thu, 29 Nov 2012 13:09:24 +0000 Subject: [PATCH] Fix for bug: exception when version a document with empty version description. --- .../splat/service/PublicationServiceImpl.java | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java index c251906..50abe39 100644 --- a/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java @@ -104,7 +104,8 @@ public class PublicationServiceImpl implements PublicationService { * * @see org.splat.service.PublicationService#copy(org.splat.dal.bo.som.Publication, org.splat.dal.bo.som.ProjectElement) */ - public Publication copy(final Publication aPublication, final ProjectElement publisher) { + public Publication copy(final Publication aPublication, + final ProjectElement publisher) { Publication copy = new Publication(); copy.setValue(aPublication.value()); copy.setStep(aPublication.getStep()); // May not be initialized yet @@ -116,9 +117,11 @@ public class PublicationServiceImpl implements PublicationService { return copy; } - /** + /** * {@inheritDoc} - * @see org.splat.service.PublicationService#versionDocument(org.splat.som.Step, org.splat.dal.bo.kernel.User, java.lang.String, long, java.lang.String, java.lang.String, org.splat.dal.bo.som.ProgressState, java.util.Date, java.lang.String[], long[]) + * + * @see org.splat.service.PublicationService#versionDocument(org.splat.som.Step, org.splat.dal.bo.kernel.User, java.lang.String, long, + * java.lang.String, java.lang.String, org.splat.dal.bo.som.ProgressState, java.util.Date, java.lang.String[], long[]) */ @Transactional public void versionDocument(final Step step, final User user, @@ -140,8 +143,11 @@ public class PublicationServiceImpl implements PublicationService { (date != null)) { dprop.setDate(date); } + if ((summary != null) && (summary.length() > 0)) { + dprop.setDescription(summary); + } next = getStepService().versionDocument(step, current, - dprop.setAuthor(user).setDescription(summary)); + dprop.setAuthor(user)); updir = next.getSourceFile().asFile(); if (LOG.isInfoEnabled()) { LOG.info("Moving \"" + upfile.getName() + "\" to \"" @@ -205,18 +211,12 @@ public class PublicationServiceImpl implements PublicationService { } } -/* protected Publication getPublication(int index, List steps) { - for (Iterator i = steps.iterator(); i.hasNext();) { - List published = i.next().getAllDocuments(); - for (Iterator j = published.iterator(); j.hasNext();) { - Publication found = j.next(); // In a given study step, - if (found.value().getIndex() == index) - return found; // there is only one publication of a given document - } - } - return null; - } -*/ + /* + * protected Publication getPublication(int index, List steps) { for (Iterator i = steps.iterator(); i.hasNext();) { List + * published = i.next().getAllDocuments(); for (Iterator j = published.iterator(); j.hasNext();) { Publication found = + * j.next(); // In a given study step, if (found.value().getIndex() == index) return found; // there is only one publication of a given + * document } } return null; } + */ /** * {@inheritDoc} * @@ -225,16 +225,17 @@ public class PublicationServiceImpl implements PublicationService { @Transactional public Timestamp approve(final Publication aPublication, final Date adate) { Timestamp res = null; - if (!(aPublication.isOutdated() || (aPublication.value().getProgressState() != ProgressState.inCHECK))) { + if (!(aPublication.isOutdated() || (aPublication.value() + .getProgressState() != ProgressState.inCHECK))) { DocumentType type = aPublication.value().getType(); Study owner = aPublication.getOwnerStudy(); - ValidationCycle cycle = getStudyService().getValidationCycleOf(owner, - type); + ValidationCycle cycle = getStudyService().getValidationCycleOf( + owner, type); User approver = cycle.getActor(ValidationStep.APPROVAL); - Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication - .value(), approver, adate); + Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, + aPublication.value(), approver, adate); getTimestampDAO().create(stamp); - + if (getDocumentService().promote(aPublication.value(), stamp)) { res = stamp; if (getDocumentService().isStudyResult(type) @@ -597,7 +598,8 @@ public class PublicationServiceImpl implements PublicationService { * the format * @return the created "Converts" relation */ - public ConvertsRelation attach(final Publication aPublication, final String format) { + public ConvertsRelation attach(final Publication aPublication, + final String format) { return getDocumentService().attach(aPublication.value(), format); } @@ -612,8 +614,8 @@ public class PublicationServiceImpl implements PublicationService { * the description of the relation * @return the created "Converts" relation */ - public ConvertsRelation attach(final Publication aPublication, final String format, - final String description) { + public ConvertsRelation attach(final Publication aPublication, + final String format, final String description) { return getDocumentService().attach(aPublication.value(), format, description); } @@ -789,6 +791,7 @@ public class PublicationServiceImpl implements PublicationService { /** * Get the timestampDAO. + * * @return the timestampDAO */ public TimestampDAO getTimestampDAO() { @@ -797,7 +800,9 @@ public class PublicationServiceImpl implements PublicationService { /** * Set the timestampDAO. - * @param timestampDAO the timestampDAO to set + * + * @param timestampDAO + * the timestampDAO to set */ public void setTimestampDAO(final TimestampDAO timestampDAO) { _timestampDAO = timestampDAO; -- 2.39.2