- // -------------------------
-
- setMenuProperty("study");
- setTitleProperty("study");
- setEditDisabledProperty("true");
- initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
-
- if (action == ToDo.cancel)
- return "cancel";
- if (doctype == 0) {
- setErrorCode("import.type");
- return ERROR;
- }
- try {
- // Getting user inputs
- mystudy = getOpenStudy();
- User user = getConnectedUser();
- Step step = mystudy.getSelectedStep();
- DocumentType type = getDocumentTypeService().selectType((int)doctype);
- File updir = getRepositoryService().getDownloadDirectory(user);
- File upfile = new File(updir.getPath() + "/" + filename);
- String[] table = filename.split("\\x2E");
-
- // Creation of the document
- Document.Properties dprop = new Document.Properties();
- Publication addoc;
-
- if (docref.length() == 0) { // Importation of a foreign document
- // TODO: Extract property of supported documents (DOCX, ODT...)
- addoc = getStepService().createDocument(step, dprop.setName(docname)
- .setType(type).setFormat(table[table.length - 1])
- .setAuthor(user));
- updir = addoc.getSourceFile().asFile();
- if (logger.isInfoEnabled())
- logger.info("Moving \"" + upfile.getName() + "\" to \""
- + updir.getPath() + "\".");
- upfile.renameTo(updir);
- try {
- getPublicationService().saveAs(addoc, state); // May throw FileNotFound if rename was not done
- } catch (FileNotFoundException saverror) {
- Thread.sleep(1000);
- logger.info("Waiting for the file.");
- upfile.renameTo(updir);
- getPublicationService().saveAs(addoc, state); // Forget it if throw again FileNotFound
- }
- } else { // Importation of a previously created template-based document
- if (date.length() > 0) {
+ String res = ERROR;
+
+ initializationScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU,
+ Constants.TRUE);
+
+ if (_documentType == 0) {
+ setErrorCode("message.error.import.type");
+
+ initializationFullScreenContext(Constants.STUDY_MENU,
+ Constants.STUDY_MENU, Constants.TRUE, Constants.NONE,
+ Constants.STUDY_MENU);
+ } else {
+ try {
+ // Getting user inputs
+ _mystudy = getOpenStudy();
+ User user = getConnectedUser();
+ Step step = _mystudy.getSelectedStep();
+ Date aDate = null;
+ if (getDocumentDate().length() > 0) {