Salome HOME
Fix for bug: exception when version a document with empty version description.
authorrkv <rkv@opencascade.com>
Thu, 29 Nov 2012 13:09:24 +0000 (13:09 +0000)
committerrkv <rkv@opencascade.com>
Thu, 29 Nov 2012 13:09:24 +0000 (13:09 +0000)
Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java

index c25190697313029383f7ddd670144ba6867476c4..50abe39f8d3e2229e14348e202a2a463423f25de 100644 (file)
@@ -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<Step> steps) {
-               for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
-                       List<Publication> published = i.next().getAllDocuments();
-                       for (Iterator<Publication> 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<Step> steps) { for (Iterator<Step> i = steps.iterator(); i.hasNext();) { List<Publication>
+        * published = i.next().getAllDocuments(); for (Iterator<Publication> 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;