[jboss-svn-commits] JBL Code SVN: r6188 - in labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins: cc codelines

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 12 19:24:34 EDT 2006


Author: wrzep
Date: 2006-09-12 19:24:29 -0400 (Tue, 12 Sep 2006)
New Revision: 6188

Added:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBrokenBuildsPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBuildAttemptsPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBuildsPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcSuccessfulBuildsPlugin.java
Modified:
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java
   labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java
Log:
http://jira.jboss.org/jira/browse/JBLAB-760
Overall QA Statistics

Pawel


Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBrokenBuildsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBrokenBuildsPlugin.java	2006-09-12 22:45:20 UTC (rev 6187)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBrokenBuildsPlugin.java	2006-09-12 23:24:29 UTC (rev 6188)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.cc;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+*/
+
+public class CcBrokenBuildsPlugin extends CcBuildsPlugin {
+
+	@Override
+	protected String getPattern() {
+		
+		return "Number of Broken Builds";
+	}	
+}
\ No newline at end of file

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBuildAttemptsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBuildAttemptsPlugin.java	2006-09-12 22:45:20 UTC (rev 6187)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBuildAttemptsPlugin.java	2006-09-12 23:24:29 UTC (rev 6188)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.cc;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+*/
+
+public class CcBuildAttemptsPlugin extends CcBuildsPlugin {
+
+	@Override
+	protected String getPattern() {
+		
+		return "Number of Build Attempts";
+	}
+}
\ No newline at end of file

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBuildsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBuildsPlugin.java	2006-09-12 22:45:20 UTC (rev 6187)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcBuildsPlugin.java	2006-09-12 23:24:29 UTC (rev 6188)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.cc;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.forge.status.plugins.Plugin;
+import org.jboss.logging.Logger;
+
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+*/
+
+public abstract class CcBuildsPlugin extends Plugin {
+
+	
+	protected abstract String getPattern();
+	
+	protected Logger log = Logger.getLogger(CcBuildsPlugin.class);
+	
+	protected Map<String,Long> cachedValues = new HashMap<String,Long>();
+	
+	@Override
+	public long getValue(String projectId) {
+		
+		if (cachedValues.containsKey(projectId)) {
+			
+			return cachedValues.get(projectId);
+		}
+		
+		List<String> URLs = CcStatusPlugin.getCcURLs(projects, projectId);
+		
+		if (URLs == null) {
+			
+			cachedValues.put(projectId, (long) 0);
+			return 0;
+		}
+		
+		long v = 0;
+		
+		for (String url : URLs) {
+			
+			v += get(url);
+		}
+		
+		cachedValues.put(projectId, v);
+		
+		return v;
+	}
+
+	private long get(String urlString) {
+		
+		urlString = urlString.concat("?tab=metrics");
+		
+		URL url;
+		String string;
+		StringBuilder stringBuilder = new StringBuilder();
+		
+		try {
+			url = new URL(urlString);
+			
+			InputStream is = url.openStream();
+			BufferedReader in = new BufferedReader(new InputStreamReader(is));
+			
+			String decodedString;
+			
+			while ((decodedString = in.readLine()) != null) {
+				
+				stringBuilder.append(decodedString);
+			    
+			}
+			
+			in.close();
+			
+		} catch (IOException e) {
+			
+			log.warn("Could not obtain statistics from " + urlString);
+			
+			return 0;
+		}
+		
+		string = stringBuilder.toString();
+		
+		Pattern pattern = Pattern.compile("<tr><td>" + getPattern() +
+												"</td><td>([0-9]*)</td></tr>");
+
+	    Matcher matcher = pattern.matcher(string);
+	    
+	    if (!matcher.find()) { 
+        	
+	    	return 0;
+	    }
+	    
+	    String resString = matcher.group(1);
+		
+		return Long.parseLong(resString);
+		
+	}	
+	
+}
\ No newline at end of file

Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java	2006-09-12 22:45:20 UTC (rev 6187)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java	2006-09-12 23:24:29 UTC (rev 6188)
@@ -26,6 +26,7 @@
 import java.util.List;
 import java.net.MalformedURLException;
 
+import org.jboss.forge.common.projects.Projects;
 import org.jboss.forge.status.common.Tags;
 import org.jboss.forge.status.plugins.KosmosStatusPlugin;
 import org.jboss.forge.status.tools.Tools;
@@ -62,7 +63,7 @@
 	protected List<CcProject> getProjectServices(String projectId) {
 		
 		// Get project cc URLs
-	    List<String> ccURLs = getCcURLs(projectId);
+	    List<String> ccURLs = getCcURLs(projects, projectId);
 		
 	    if ((ccURLs == null) || (ccURLs.isEmpty())) {
 	    	return null;
@@ -96,7 +97,7 @@
 	}
 
 
-	private List<String> getCcURLs(String projectId) {
+	public static List<String> getCcURLs(Projects projects, String projectId) {
 		
 		String ccURLsString =
 				projects.getProjectProperty(projectId, Tags.CC_ADRESS_TAG);
@@ -111,7 +112,7 @@
 	@Override
 	public String getLink(String projectId) {
 		
-		List<String> ccURLsString = getCcURLs(projectId);
+		List<String> ccURLsString = getCcURLs(projects, projectId);
 		
 		return (ccURLsString == null) ? null : ccURLsString.get(0);
 	}

Added: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcSuccessfulBuildsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcSuccessfulBuildsPlugin.java	2006-09-12 22:45:20 UTC (rev 6187)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcSuccessfulBuildsPlugin.java	2006-09-12 23:24:29 UTC (rev 6188)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.forge.status.plugins.cc;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz @ jboss . com)
+*/
+
+public class CcSuccessfulBuildsPlugin extends CcBuildsPlugin {
+
+	@Override
+	protected String getPattern() {
+		
+		return "Number of Successful Builds";
+	}
+}
\ No newline at end of file

Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java	2006-09-12 22:45:20 UTC (rev 6187)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/codelines/CodeLinesPlugin.java	2006-09-12 23:24:29 UTC (rev 6188)
@@ -73,7 +73,7 @@
 				String password = repo.getPassword();
 				
 				log.info("Analyzing repository " + url + 
-											"(project: " + projectId + ")..."); 
+											" (project: " + projectId + ")..."); 
 				
 				cl = getValue(url, userName, password);
 				




More information about the jboss-svn-commits mailing list