From: rkv Date: Mon, 28 Jan 2013 11:58:46 +0000 (+0000) Subject: The complex method has been decomposed. X-Git-Tag: Root_Delivery2_2013_04_22~159 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2ffeaea140b944673c9b44fa3658ddd1fc5865b1;p=tools%2Fsiman.git The complex method has been decomposed. --- diff --git a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java index 6365f7e..d1b82f5 100644 --- a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java @@ -626,33 +626,51 @@ public class ScenarioServiceImpl implements ScenarioService { // Remeber the new document newDocs.add(newPub); } + saveFile(newPub, step, file); + } + } - // Attach the file to the created document - java.io.File updir = newPub.getSourceFile().asFile(); - if (LOG.isDebugEnabled()) { - LOG.debug("Moving \"" + upfile.getName() + "\" to \"" - + updir.getPath() + "\"."); - } - if (updir.exists()) { - if (updir.delete()) { - LOG.info(MessageKeyEnum.SCN_000003.toString(), updir - .getAbsoluteFile(), step.getOwner().getIndex()); - } else { - throw new IOException( - "Can't delete the existing destination file to move file from " - + file.getPath() + " to " - + updir.getAbsolutePath()); - } - } - if (upfile.renameTo(updir)) { - // Save the new publication in the scenario. - // The old publication is removed from the scenario here. - getPublicationService().saveAs(newPub, ProgressState.inWORK); // May throw FileNotFound if rename was not done + /** + * Save the file in the vault and create its publication in the step. + * @param newPub + * the new publication to save + * @param step + * the study step to publish the document + * @param file + * the downloaded file DTO + * @throws IOException + * if a file can't be moved into the vault + * @throws NotApplicableException + * if failed saving of a new publication with a given state + */ + private void saveFile(final Publication newPub, final Step step, + final FileDTO file) throws IOException, NotApplicableException { + // Attach the file to the created document + java.io.File updir = newPub.getSourceFile().asFile(); + java.io.File upfile = new java.io.File(file.getPath()); + if (LOG.isDebugEnabled()) { + LOG.debug("Moving \"" + upfile.getName() + "\" to \"" + + updir.getPath() + "\"."); + } + if (updir.exists()) { + if (updir.delete()) { + LOG.info(MessageKeyEnum.SCN_000003.toString(), updir + .getAbsoluteFile(), step.getOwner().getIndex()); } else { - throw new IOException("Can't move file from " + file.getPath() - + " to " + updir.getAbsolutePath()); + throw new IOException( + "Can't delete the existing destination file to move file from " + + file.getPath() + " to " + + updir.getAbsolutePath()); } } + if (upfile.renameTo(updir)) { + // Save the new publication in the scenario. + // The old publication is removed from the scenario here. + getPublicationService().saveAs(newPub, ProgressState.inWORK); // May throw FileNotFound if rename was not done + } else { + throw new IOException("Can't move file from " + file.getPath() + + " to " + updir.getAbsolutePath()); + } } /**