import java.util.ResourceBundle;
import org.apache.log4j.Logger;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.splat.kernel.Do;
import org.splat.dal.bo.kernel.User;
import org.splat.manox.Toolbox;
import org.splat.manox.Writer;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.service.DocumentService;
import org.splat.service.DocumentTypeService;
import org.splat.service.StepService;
import org.splat.service.StudyService;
* Injected document type service.
*/
private DocumentTypeService _documentTypeService;
-
+ /**
+ * Injected document service.
+ */
+ private DocumentService _documentService;
/**
* The injected Study service.
*/
if (!template.exists())
return null;
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
+// Session connex = Database.getCurSession();
+// Transaction transax = connex.beginTransaction();
try {
File udir = getRepositoryService().getDownloadDirectory(author);
File credoc = new File(udir.getPath() + "/" + filename);
Document medoc = getStepService().createDocument(step,
dprop.setType(type).setFormat("xml").setAuthor(author))
.value();
- transax.commit();
+// transax.commit();
// Instantiation of the template into the user download directory
if (!udir.exists())
+ filename);
} catch (Exception saverror) {
logger.error("Reason:", saverror);
- 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 null;
}
}
if (docurl.startsWith(prefix))
try {
- Session connex = Database.getSession();
- Transaction transax = connex.beginTransaction();
String path = docurl.substring(prefix.length());
- String[] parse = path.split("'");
-
- path = parse[0];
- for (int i = 1; i < parse.length; i++)
- path = path + "''" + parse[i];
- // Better call Database.selectDocument(path), but this service does not exist (overloading issue)
- String query = "from Document where path='" + path + "'";
- Document value = (Document) Database.getSession().createQuery(
- query).uniqueResult();
+ Document value = getDocumentService().getDocumentByPath(path);
selecdoc = ustep.getDocument(value.getIndex());
- transax.commit();
} catch (Exception error) {
logger.error("Reason:", error);
}
public void setStudyService(StudyService studyService) {
_studyService = studyService;
}
+
+ /**
+ * Get the documentService.
+ * @return the documentService
+ */
+ public DocumentService getDocumentService() {
+ return _documentService;
+ }
+
+ /**
+ * Set the documentService.
+ * @param documentService the documentService to set
+ */
+ public void setDocumentService(DocumentService documentService) {
+ _documentService = documentService;
+ }
}
\ No newline at end of file