import java.io.FileNotFoundException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
private String index = null; // Versioned document index
private List<Publication> usedby = null;
- private String docusedby = null;
+ private long[] docusedby = null;
private String summary = null; // Summary of changes in the new version
private String docver = ""; // Version number extracted from the imported file, if exist
private String date = ""; // Date extracted from the imported file, if exist
if (action == ToDo.cancel)
return "cancel";
- Session connex = Database.getCurSession();
- Transaction transax = connex.beginTransaction();
try {
// Getting user inputs
mystudy = getOpenStudy();
User user = getConnectedUser();
Step step = mystudy.getSelectedStep();
- File updir = getRepositoryService().getDownloadDirectory(user);
+// List<Step> steps = mystudy.getInvolvedSteps();
+ Date aDate = null;
+ if (date.length() > 0) {
+ ResourceBundle locale = ResourceBundle.getBundle("som",
+ ApplicationSettings.getCurrentLocale());
+ SimpleDateFormat get = new SimpleDateFormat(
+ locale.getString("date.format"));
+ aDate = get.parse(date);
+ }
+
+ String[] listDocuses = null;
+ if (docuses != null) {
+ listDocuses = docuses.split(",");
+ }
+ getPublicationService().versionDocument(step, user, filename, Integer.valueOf(index), docver,
+ summary, state, aDate, listDocuses, docusedby/*, steps*/);
+ /* File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
// Versioning of the document
if (!compatible.contains(using.getIndex()))
getPublicationService().outdate(using);
}
+*/
// Update of the open study
mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
// TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
- transax.commit();
return SUCCESS;
} catch (FileNotFoundException error) {
logger.error("Reason:", error);
logger.error("Reason:", error);
setErrorCode("internal");
}
- if (transax != null && transax.isActive()) {
- // Second try-catch as the rollback could fail as well
- try {
- transax.rollback();
- } catch (HibernateException backerror) {
- logger.debug("Error rolling back transaction", backerror);
- }
- }
return ERROR;
}
this.index = index;
}
- public void setUsedBy(String list) {
+ public void setUsedBy(long[] list) {
// -----------------------------------
this.docusedby = list;
}