aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpom.xml2
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/core/db/FileDao.java11
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java30
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java22
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java1
-rwxr-xr-x[-rw-r--r--]src/main/java/io/trygvis/esper/testing/jenkins/JenkinsJobDto.java4
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java2
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/xml/JenkinsJobXml.java44
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java14
-rwxr-xr-xsrc/main/resources/queries.sql2
-rwxr-xr-x[-rw-r--r--]src/main/webapp/apps/buildApp/build.html2
-rwxr-xr-x[-rw-r--r--]src/main/webapp/apps/jenkinsApp/job.html2
-rwxr-xr-x[-rw-r--r--]src/main/webapp/apps/personApp/person.html5
13 files changed, 100 insertions, 41 deletions
diff --git a/pom.xml b/pom.xml
index 9482a08..0224a0f 100755
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
<dependency>
<groupId>io.trygvis.appsh</groupId>
<artifactId>booter-jetty</artifactId>
- <version>8.1.7.v20120910+1</version>
+ <version>8.1.8.v20121106+2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
diff --git a/src/main/java/io/trygvis/esper/testing/core/db/FileDao.java b/src/main/java/io/trygvis/esper/testing/core/db/FileDao.java
index affe1c8..a7d7199 100755
--- a/src/main/java/io/trygvis/esper/testing/core/db/FileDao.java
+++ b/src/main/java/io/trygvis/esper/testing/core/db/FileDao.java
@@ -41,4 +41,15 @@ public class FileDao {
return some(rs.getBinaryStream(1));
}
}
+
+ public SqlOption<InputStream> loadByUrl(URI uri) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("SELECT data FROM file WHERE url=?")) {
+ s.setString(1, uri.toASCIIString());
+ ResultSet rs = s.executeQuery();
+ if(!rs.next()) {
+ return none();
+ }
+ return some(rs.getBinaryStream(1));
+ }
+ }
}
diff --git a/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java b/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
index 3270db1..4689e4d 100755
--- a/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
+++ b/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
@@ -42,10 +42,35 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback<JenkinsBui
Daos daos = new Daos(c);
final BuildDao buildDao = daos.buildDao;
+ JenkinsJobDto jobDto = daos.jenkinsDao.selectJob(jenkinsBuild.job).get();
+
+ SqlOption<InputStream> jobXmlFileO = daos.fileDao.load(jobDto.file);
+
+ if (jobXmlFileO.isNone()) {
+ logger.warn("Job xml file unavailable: File.uuid={}", jobDto.file);
+ return;
+ }
+
+ Option<JenkinsJobXml> jobXmlO = xmlParser.parseDocument.f(jobXmlFileO.get()).
+ bind(JenkinsJobXml.parse);
+
+ if (jobXmlO.isNone()) {
+ logger.warn("Could not parse job file: File.uuid={}", jobDto.file);
+ return;
+ }
+
+ JenkinsJobXml jobXml = jobXmlO.some();
+
+ switch (jobXml.type) {
+ case MAVEN_MODULE:
+ logger.info("Skipping maven module, Job.uuid={}", jobDto.uuid);
+ return;
+ }
+
SqlOption<InputStream> file = daos.fileDao.load(jenkinsBuild.file);
if (file.isNone()) {
- logger.warn("File unavailable: " + jenkinsBuild.file);
+ logger.warn("Build file unavailable: " + jenkinsBuild.file);
return;
}
@@ -78,6 +103,7 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback<JenkinsBui
// This happens if no one has claimed the user id.
if (personO.isNone()) {
+ logger.info("unknown person: " + user);
unknownPersons++;
continue;
}
@@ -91,7 +117,5 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback<JenkinsBui
logger.info("Created build uuid={}, #participants={}, #knownPersons={}, #unknonwnPersons={}", uuidBuild,
jenkinsBuild.users.length, knownPersons, unknownPersons);
-
- throw new SQLException("wat");
}
}
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java
index 24ea6d9..d93651d 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java
@@ -3,7 +3,6 @@ package io.trygvis.esper.testing.jenkins;
import fj.*;
import fj.data.*;
import io.trygvis.esper.testing.jenkins.xml.*;
-import io.trygvis.esper.testing.jenkins.xml.JenkinsJobXml.*;
import io.trygvis.esper.testing.util.*;
import org.apache.abdera.*;
import org.apache.abdera.model.*;
@@ -111,23 +110,14 @@ public class JenkinsClient {
Element root = d.some()._1().getRootElement();
- String name = root.getName();
+ Option<JenkinsJobXml> xml = JenkinsJobXml.parse(root);
- switch (name) {
- case "freeStyleProject":
- return some(p(JenkinsJobXml.parse(url, JenkinsJobType.FREE_STYLE, root), d.some()._2()));
- case "mavenModuleSet":
- return some(p(JenkinsJobXml.parse(url, JenkinsJobType.MAVEN_MODULE_SET, root), d.some()._2()));
- case "mavenModule":
- return some(p(JenkinsJobXml.parse(url, JenkinsJobType.MAVEN_MODULE, root), d.some()._2()));
- case "matrixProject":
- return some(p(JenkinsJobXml.parse(url, JenkinsJobType.MATRIX, root), d.some()._2()));
- case "matrixConfiguration":
- return some(p(JenkinsJobXml.parse(url, JenkinsJobType.MATRIX_CONFIGURATION, root), d.some()._2()));
- default:
- logger.warn("Unknown project type: " + name);
- return Option.none();
+ if(xml.isNone()) {
+ logger.warn("Unable to parse xml");
+ return none();
}
+
+ return some(p(xml.some(), d.some()._2()));
}
public Option<P2<JenkinsBuildXml, byte[]>> fetchBuild(URI url) {
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
index aec9ab3..ee793fa 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
@@ -48,6 +48,7 @@ public class JenkinsDao {
UUID.fromString(rs.getString(i++)),
new DateTime(rs.getTimestamp(i++).getTime()),
UUID.fromString(rs.getString(i++)),
+ UUID.fromString(rs.getString(i++)),
URI.create(rs.getString(i++)),
fromNull(rs.getString(i)));
}
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsJobDto.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsJobDto.java
index 2fb5b99..e540a2a 100644..100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsJobDto.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsJobDto.java
@@ -9,12 +9,14 @@ import java.util.*;
public class JenkinsJobDto extends AbstractEntity {
public final UUID server;
+ public final UUID file;
public final URI url;
public final Option<String> displayName;
- JenkinsJobDto(UUID uuid, DateTime createdDate, UUID server, URI url, Option<String> displayName) {
+ public JenkinsJobDto(UUID uuid, DateTime createdDate, UUID server, UUID file, URI url, Option<String> displayName) {
super(uuid, createdDate);
this.server = server;
+ this.file = file;
this.url = url;
this.displayName = displayName;
}
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java
index c603506..8195f01 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java
@@ -17,6 +17,6 @@ public class JenkinsServerDto extends AbstractEntity {
}
public URI userUrl(String id) {
- return URI.create(url.toASCIIString() + "/users/" + id);
+ return URI.create(url.toASCIIString() + "/user/" + id);
}
}
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/xml/JenkinsJobXml.java b/src/main/java/io/trygvis/esper/testing/jenkins/xml/JenkinsJobXml.java
index eb4c874..8cbeb9d 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/xml/JenkinsJobXml.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/xml/JenkinsJobXml.java
@@ -2,19 +2,36 @@ package io.trygvis.esper.testing.jenkins.xml;
import java.net.URI;
-import org.jdom2.Element;
+import org.jdom2.*;
import fj.F;
import fj.data.Option;
import io.trygvis.esper.testing.Util;
-import static fj.data.Option.some;
+import static fj.data.Option.*;
import static io.trygvis.esper.testing.Util.child;
import static io.trygvis.esper.testing.Util.childText;
public class JenkinsJobXml {
public enum JenkinsJobType {
- FREE_STYLE, MAVEN_MODULE_SET, MAVEN_MODULE, MATRIX, MATRIX_CONFIGURATION
+ FREE_STYLE, MAVEN_MODULE_SET, MAVEN_MODULE, MATRIX, MATRIX_CONFIGURATION;
+
+ public static Option<JenkinsJobType> fromElement(String name) {
+ switch (name) {
+ case "freeStyleProject":
+ return some(FREE_STYLE);
+ case "mavenModuleSet":
+ return some(MAVEN_MODULE_SET);
+ case "mavenModule":
+ return some(MAVEN_MODULE);
+ case "matrixProject":
+ return some(MATRIX);
+ case "matrixConfiguration":
+ return some(MATRIX_CONFIGURATION);
+ default:
+ return none();
+ }
+ }
}
public final JenkinsJobType type;
@@ -71,18 +88,31 @@ public class JenkinsJobXml {
}
}
- public static JenkinsJobXml parse(URI url, JenkinsJobType type, Element root) {
- return new JenkinsJobXml(type,
+ public static final F<Document, Option<JenkinsJobXml>> parse = new F<Document, Option<JenkinsJobXml>>() {
+ public Option<JenkinsJobXml> f(Document document) {
+ return parse(document.getRootElement());
+ }
+ };
+
+ public static Option<JenkinsJobXml> parse(Element root) {
+ Option<URI> uri = childText(root, "url").bind(Util.parseUri);
+ Option<JenkinsJobType> typeO = JenkinsJobType.fromElement(root.getName());
+
+ if (uri.isNone() || typeO.isNone()) {
+ return none();
+ }
+
+ return some(new JenkinsJobXml(typeO.some(),
childText(root, "description"),
childText(root, "displayName"),
childText(root, "name"),
- childText(root, "url").bind(Util.parseUri).orSome(url),
+ uri.some(),
childText(root, "color"),
childText(root, "buildable").bind(Util.parseBoolean).orSome(false),
child(root, "lastBuild").bind(BuildXml.buildXml),
child(root, "lastCompletedBuild").bind(BuildXml.buildXml),
child(root, "lastFailedBuild").bind(BuildXml.buildXml),
child(root, "lastSuccessfulBuild").bind(BuildXml.buildXml),
- child(root, "lastUnsuccessfulBuild").bind(BuildXml.buildXml));
+ child(root, "lastUnsuccessfulBuild").bind(BuildXml.buildXml)));
}
}
diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java b/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java
index 7548a32..f006261 100755
--- a/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java
+++ b/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java
@@ -107,7 +107,7 @@ public class CoreResource extends AbstractResource {
List<BuildJson> list = new ArrayList<>();
for (BuildDto build : buildDtos) {
- list.add(getBuildJson(daos, build));
+ list.add(getBuildJson(build));
}
return list;
}
@@ -138,23 +138,23 @@ public class CoreResource extends AbstractResource {
return Option.none();
}
- return Option.some(getBuildJson(daos, o.get()));
+ return Option.some(getBuildJson(o.get()));
}
});
}
- private BuildJson getBuildJson(Daos daos, BuildDto build) {
- return new BuildJson(build.uuid, build.createdDate, build.success);
+ private BuildJson getBuildJson(BuildDto build) {
+ return new BuildJson(build.uuid, build.timestamp, build.success);
}
public static class BuildJson {
public final UUID uuid;
- public final DateTime date;
+ public final DateTime timestamp;
public final boolean success;
- public BuildJson(UUID uuid, DateTime date, boolean success) {
+ public BuildJson(UUID uuid, DateTime timestamp, boolean success) {
this.uuid = uuid;
- this.date = date;
+ this.timestamp = timestamp;
this.success = success;
}
}
diff --git a/src/main/resources/queries.sql b/src/main/resources/queries.sql
new file mode 100755
index 0000000..66bdb38
--- /dev/null
+++ b/src/main/resources/queries.sql
@@ -0,0 +1,2 @@
+-- All unclaimed jenkins users
+select absolute_url from jenkins_user where uuid not in (select jenkins_user from person_jenkins_user);
diff --git a/src/main/webapp/apps/buildApp/build.html b/src/main/webapp/apps/buildApp/build.html
index b2d4bd9..2feee28 100644..100755
--- a/src/main/webapp/apps/buildApp/build.html
+++ b/src/main/webapp/apps/buildApp/build.html
@@ -9,7 +9,7 @@
<table>
<tr>
<th>Date</th>
- <td>{{build.date | date:'medium'}}</td>
+ <td>{{build.timestamp | date:'medium'}}</td>
</tr>
<tr>
<th>Status</th>
diff --git a/src/main/webapp/apps/jenkinsApp/job.html b/src/main/webapp/apps/jenkinsApp/job.html
index 5113d2e..6ee7af0 100644..100755
--- a/src/main/webapp/apps/jenkinsApp/job.html
+++ b/src/main/webapp/apps/jenkinsApp/job.html
@@ -36,7 +36,7 @@
</thead>
<tbody>
<tr ng-repeat="build in builds.rows" class="{{{true: 'success', false: 'error'}[build.success]}}">
- <td>{{build.createdDate | date:'medium'}}</td>
+ <td>{{build.timestamp | date:'medium'}}</td>
<td>{{build.result}}</td>
<td><a class="btn" ng-click="showBuild(build.uuid)"><i class="icon-chevron-right"></i></a></td>
</tr>
diff --git a/src/main/webapp/apps/personApp/person.html b/src/main/webapp/apps/personApp/person.html
index 83aea0a..056545f 100644..100755
--- a/src/main/webapp/apps/personApp/person.html
+++ b/src/main/webapp/apps/personApp/person.html
@@ -33,7 +33,7 @@
</thead>
<tbody>
<tr ng-repeat="build in recentBuilds" class="{{{true: 'success', false: 'error'}[build.success]}}">
- <td>{{build.date | date:'medium'}}</td>
+ <td>{{build.timestamp | date:'medium'}}</td>
<td>{{build.success}}</td>
<td><a href="/build/{{build.uuid}}">Details</a></td>
</tr>
@@ -52,7 +52,7 @@
</thead>
<tbody>
<tr ng-repeat="build in builds.rows" class="{{{true: 'success', false: 'error'}[build.success]}}">
- <td>{{build.date | date:'medium'}}</td>
+ <td>{{build.timestamp | date:'medium'}}</td>
<td>{{build.success}}</td>
</tr>
</tbody>
@@ -72,5 +72,4 @@
</tfoot>
</table>
</div>
-
</div>