STD-000001=Unable to re-index the study #{1}, reason: {2}
SCN-000001=Scenario doesn't contain the step number #{1}
SCN-000002=Scenario doesn't contain the document #{1}
+SCN-000003=The existing file {1} has been deleted when check-in the scenario #{2}
+SCN-000004=Can not delete the existing destination file to move file from {1} to {2} when check-in the scenario #{3}
+SCN-000005=Can not move file from {1} to {2} when check-in the scenario #{3}
KNT-000001=Knowledge element type "{1}" already exists
SCT-000001=Simulation context type "{1}" already exists
DCT-000001=Document type "{1}" already exists
STD-000001=Unable to re-index the study #{1}, reason: {2}
SCN-000001=Scenario doesn't contain the step number #{1}
SCN-000002=Scenario doesn't contain the document #{1}
+SCN-000003=The existing file {1} has been deleted when check-in the scenario #{2}
+SCN-000004=Can not delete the existing destination file to move file from {1} to {2} when check-in the scenario #{3}
+SCN-000005=Can not move file from {1} to {2} when check-in the scenario #{3}
KNT-000001=Knowledge element type "{1}" already exists
SCT-000001=Simulation context type "{1}" already exists
DCT-000001=Document type "{1}" already exists
* Scenario doesn't contain the document #{1}.
*/
SCN_000002("SCN-000002"),
+ /**
+ * The existing file {1} has been deleted when check-in the scenario #{2}.
+ */
+ SCN_000003("SCN-000003"),
+ /**
+ * Can not delete the existing destination file to move file from {1} to {2} when check-in the scenario #{3}.
+ */
+ SCN_000004("SCN-000004"),
+ /**
+ * Can not move file from {1} to {2} when check-in the scenario #{3}.
+ */
+ SCN_000005("SCN-000005"),
/**
* Simulation context type "{1}" already exists.
*/
import java.util.List;
import java.util.Map;
-import org.apache.log4j.Logger;
import org.splat.common.properties.MessageKeyEnum;
import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.kernel.User;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
import org.splat.kernel.NotApplicableException;
+import org.splat.log.AppLogger;
import org.splat.service.dto.DocumentDTO;
import org.splat.service.dto.FileDTO;
import org.splat.service.dto.StepDTO;
public class ScenarioServiceImpl implements ScenarioService {
/**
- * Logger for this class.
+ * The logger for the service.
*/
- protected final static Logger LOG = Logger
+ public final static AppLogger LOG = AppLogger
.getLogger(ScenarioServiceImpl.class);
/**
// Attach the file to the created document
updir = newPub.getSourceFile().asFile();
- if (LOG.isInfoEnabled()) {
- LOG.info("Moving \"" + upfile.getName() + "\" to \""
+ 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(), scenId);
+ } 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
+ } else {
+ throw new IOException("Can't move file from "
+ + file.getPath() + " to "
+ + updir.getAbsolutePath());
}
}
}
// For each new version copy uses relations from the previous version.
for (Publication newVer : newVers) {
// For each Uses relation of the previous version
- Document prevDoc = newVer.value().getPreviousVersion();//prevVersion.get(newVer);
+ Document prevDoc = newVer.value().getPreviousVersion();// prevVersion.get(newVer);
if (LOG.isDebugEnabled()) {
LOG.debug("Previous version for publication #"
+ newVer.getIndex() + " is found: " + prevDoc);
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, RuntimeException {
User nuser = new User(uprop);
+ // Do merge to synchronize Role object with the current hibernate session
+ // and to avoid th exception:
+ // org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the
+ // session: [org.splat.dal.bo.kernel.Role#simer]
+ getUserDAO().merge(nuser);
+
getUserDAO().create(nuser);
return nuser;
}
if (members.contains(uname)) {
continue; // This user already exists
}
- uprop.setUsername(uname)
- .setFirstName(row.get("first").getTextContent())
- .setName(row.get("last").getTextContent())
- .setMailAddress(row.get("mail").getTextContent())
- .addRole(row.get("role").getTextContent()); // Add all roles at a time
+ uprop.setUsername(uname).setFirstName(
+ row.get("first").getTextContent()).setName(
+ row.get("last").getTextContent()).setMailAddress(
+ row.get("mail").getTextContent()).addRole(
+ row.get("role").getTextContent()); // Add all roles at a time
// Optional properties
org.w3c.dom.Node node = row.get("password");
return imported;
} catch (IOException error) {
LOG.debug(error.getMessage(), error);
- throw new XMLException("XML users file not found"); //RKV: NOPMD: Original message is printed
+ throw new XMLException("XML users file not found"); // RKV: NOPMD: Original message is printed
} catch (ParserConfigurationException e) {
LOG.debug(e.getMessage(), e);
- throw new XMLException("XML Organization parser not accessible"); //RKV: NOPMD: Original message is printed
+ throw new XMLException("XML Organization parser not accessible"); // RKV: NOPMD: Original message is printed
} catch (Exception e) {
LOG.debug(e.getMessage(), e);
- throw new XMLException("XML users file not valid"); //RKV: NOPMD: Original message is printed
+ throw new XMLException("XML users file not valid"); // RKV: NOPMD: Original message is printed
}
}
// but this requires a getPassword in User.Properties nested class.
Criterion aCondition = Restrictions.eq("username", username);
if (password == null) {
- aCondition = Restrictions.and(aCondition,
- Restrictions.isNull("password"));
+ aCondition = Restrictions.and(aCondition, Restrictions
+ .isNull("password"));
} else {
- aCondition = Restrictions.and(
- aCondition,
- Restrictions.eq("password",
- String.valueOf(password.hashCode())));
+ aCondition = Restrictions.and(aCondition, Restrictions.eq(
+ "password", String.valueOf(password.hashCode())));
}
return getUserDAO().findByCriteria(aCondition);
}
@SuppressWarnings("unchecked")
public List<User> selectUsersWhere(final User.Properties... uprop) {
-// StringBuffer query = new StringBuffer("FROM User");
-// String separator = " where (";
-// String value;
-//
-// for (int i = 0; i < uprop.length; i++) {
-//
-// value = uprop[i].getOrganizationName();
-// if (value != null) {
-// query = query.append(separator).append(" organid='")
-// .append(value).append("'");
-// // separator = " and";
-// }
-// separator = ") or (";
-// }
-// query.append(")");
+ // StringBuffer query = new StringBuffer("FROM User");
+ // String separator = " where (";
+ // String value;
+ //
+ // for (int i = 0; i < uprop.length; i++) {
+ //
+ // value = uprop[i].getOrganizationName();
+ // if (value != null) {
+ // query = query.append(separator).append(" organid='")
+ // .append(value).append("'");
+ // // separator = " and";
+ // }
+ // separator = ") or (";
+ // }
+ // query.append(")");
Criterion aCondition = null;
String value;
for (int i = 0; i < uprop.length; i++) {
if (aCondition == null) {
aCondition = Restrictions.eq("organid", value);
} else {
- aCondition = Restrictions.or(aCondition, Restrictions.eq("organid", value));
+ aCondition = Restrictions.or(aCondition, Restrictions.eq(
+ "organid", value));
}
}
}
import org.splat.service.DocumentTypeService;
import org.splat.service.KnowledgeElementTypeService;
import org.splat.service.SimulationContextTypeService;
+import org.springframework.transaction.annotation.Transactional;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
* @throws SQLException
* if there is a database population problem
*/
+ @Transactional
public void configure(final String filename) throws IOException,
SQLException {
if (!_steps.isEmpty()) {
* @throws MismatchException
* if checkin failed
*/
- @Test
+ @Test(groups = {"checkin", "sevice", "functional", "business"})
public void testCheckin() throws InvalidPropertyException,
MissedPropertyException, MultiplyDefinedException, IOException,
SQLException, MismatchException, NotApplicableException {
// Check that new document versions are created for checked in documents
for (StepDTO step : stepsToCheckin) {
for (DocumentDTO docDTO : step.getDocs()) {
- if (docDTO.getId() != 0) {
+ if ((docDTO.getId() != 0) && (docDTO.getId() != null)) {
boolean found = false;
Document prevDoc = null;
Publication newPub = null;
}
}
Assert.assertTrue(found,
- "New version of existing checked in document \""
+ "New version of the existing checked in document \""
+ docDTO.getTitle() + "\" (id="
+ docDTO.getId()
+ ") is not found in the scenario.");
"noreply@salome-platform.org");
uprop.disableCheck();
User anAuthor = new User(uprop);
- ht.save(anAuthor);
+ ht.saveOrUpdate(anAuthor);
// Create a test study
Study.Properties stprops = new Study.Properties().setReference(
--- /dev/null
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="SimanCommonTests" verbose="1">
+ <test name="all">
+ <method-selectors>
+ <method-selector>
+ <script language="beanshell">
+ <![CDATA[
+ (groups.containsKey("checkin")) && method.getName().toUpperCase().startsWith("TEST")
+ ]]>
+ </script>
+ </method-selector>
+ </method-selectors>
+ <groups>
+ <!--
+ <define name="all">
+ <include name="business"/>
+ <include name="functional"/>
+ <include name="service"/>
+ </define>
+ <define name="new">
+ <include name="newservice"/>
+ </define>
+ <run>
+ <include name="all"/>
+ <exclude name="old"/>
+ </run>
+ -->
+
+ </groups>
+ <packages>
+ <package name="test.*" />
+ </packages>
+ </test>
+</suite>