import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
+import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled {
/** Should only be set for an already existing result. */
private String uuid;
+ private Repository repository;
private Session session;
private String resultType = SlcTypes.SLC_RESULT;
public void init() {
try {
+ session = repository.login();
if (uuid == null) {
// create new result
uuid = UUID.randomUUID().toString();
- String path = SlcJcrUtils.createResultPath(uuid);
+ String path = SlcJcrUtils.createResultPath(session.getUserID(),
+ uuid);
Node resultNode = JcrUtils.mkdirs(session, path, resultType);
resultNode.setProperty(SLC_UUID, uuid);
for (String attr : attributes.keySet()) {
this.uuid = uuid;
}
- public void setSession(Session session) {
- this.session = session;
+ public void setRepository(Repository repository) {
+ this.repository = repository;
}
public void setResultType(String resultType) {
this.attributes = attributes;
}
- public void setLogoutWhenDestroyed(Boolean logoutWhenDestroyed) {
- this.logoutWhenDestroyed = logoutWhenDestroyed;
- }
+// public void setLogoutWhenDestroyed(Boolean logoutWhenDestroyed) {
+// this.logoutWhenDestroyed = logoutWhenDestroyed;
+// }
}
}
/** Create a new execution result path based on the current time */
- public static String createResultPath(String uuid) {
+ public static String createResultPath(String username, String uuid) {
Calendar now = new GregorianCalendar();
- return SlcJcrConstants.RESULTS_BASE_PATH + '/'
- + JcrUtils.dateAsPath(now, true) + uuid;
+ return JcrUtils.getUserHomePath(username) + '/' + SlcNames.SLC_RESULTS
+ + '/' + JcrUtils.dateAsPath(now, true) + uuid;
}
/**
protected Node createResultNode(TreeTestResult testResult)
throws RepositoryException {
String uuid = testResult.getUuid();
- String path = SlcJcrUtils.createResultPath(uuid);
+ String path = SlcJcrUtils.createResultPath(session.getUserID(), uuid);
Node resultNode = JcrUtils.mkdirs(session, path, SlcTypes.SLC_RESULT);
resultNode.setProperty(SLC_UUID, uuid);
for (Map.Entry<String, String> entry : testResult.getAttributes()