[jboss-svn-commits] JBL Code SVN: r8564 - in labs/jbosslabs/trunk/portal-extensions/jmm: jmm-common/src/java/org/jboss/forge/jmm/common jmm-common/src/java/org/jboss/forge/jmm/common/exceptions jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf jmm-portlet/src/java/org/jboss/forge/jmm/portlet/templates jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol jmm-service/src/java/org/jboss/forge/jmm/service/impl/shotoku/protocol jmm-service/src/java/org/jboss/forge/jmm/service/plugins jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math jmm-service/src/java/org/jboss/forge/jmm/service/plugins/productization jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Dec 22 16:29:20 EST 2006
Author: wrzep
Date: 2006-12-22 16:28:58 -0500 (Fri, 22 Dec 2006)
New Revision: 8564
Added:
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/GetPluginValueException.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/UnableToGetPluginValueException.java
Modified:
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/Tags.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/ScoresException.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/Plugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/PluginValues.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/PluginValuesRemote.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-portlet/src/java/org/jboss/forge/jmm/portlet/templates/MetricTemplate.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol/PluginValuesEntity.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol/ValueEntity.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/shotoku/protocol/PluginValuesImpl.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/KosmosPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcBuildsPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcErrorsPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcTestsPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/AddedCodeLinesPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesEvaluator.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesTotalPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/SlowCodeLinesTotalPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/ClosedIssuesPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/JiraPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/OpenIssuesPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/ResolvedIssuesPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/AddPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/DivPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/LastNDaysPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/MathPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/MulPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/productization/DownloadsPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsLast31DaysPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsLast7DaysPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsTodayPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsTotalPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/RevisionPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/SvnPlugin.java
labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/TotalRepoSizePlugin.java
Log:
http://jira.jboss.com/jira/browse/JBLAB-599
If sth fails inside plugin it always reports failure (and its severity) instead of returning 0 which could be
confusing.
Pawel
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/Tags.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/Tags.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/Tags.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -93,6 +93,8 @@
public static final String DAYS_TAG = "days";
public static final String PLUGIN_TAG = "plugin";
+ public static final String RETRY_ON_FAIL_PROPERTY = "retry-on-fail";
+
/**
Added: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/GetPluginValueException.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/GetPluginValueException.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/GetPluginValueException.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -0,0 +1,49 @@
+/*
+ * 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.jmm.common.exceptions;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
+*/
+
+public class GetPluginValueException extends ScoresException {
+
+ private static final long serialVersionUID = -4740311245246366603L;
+
+ public GetPluginValueException() {
+ super();
+ }
+
+ public GetPluginValueException(Exception e) {
+ super(e);
+ }
+
+ public GetPluginValueException(String msg) {
+ super(msg);
+ }
+
+ public GetPluginValueException(String msg, Throwable e) {
+ super(msg,e);
+ }
+
+}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/ScoresException.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/ScoresException.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/ScoresException.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -41,4 +41,8 @@
public ScoresException(String msg) {
super(msg);
}
+
+ public ScoresException(String msg, Throwable e) {
+ super(msg,e);
+ }
}
Added: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/UnableToGetPluginValueException.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/UnableToGetPluginValueException.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/exceptions/UnableToGetPluginValueException.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -0,0 +1,51 @@
+/*
+ * 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.jmm.common.exceptions;
+
+/**
+* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
+*
+* For reporting less severe problems than GetPluginValueEx.
+*/
+
+public class UnableToGetPluginValueException extends ScoresException {
+
+ private static final long serialVersionUID = -4740311245246366603L;
+
+ public UnableToGetPluginValueException() {
+ super();
+ }
+
+ public UnableToGetPluginValueException(Exception e) {
+ super(e);
+ }
+
+ public UnableToGetPluginValueException(String msg) {
+ super(msg);
+ }
+
+ public UnableToGetPluginValueException(String msg, Throwable e) {
+ super(msg,e);
+ }
+
+}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/Plugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/Plugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/Plugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -29,7 +29,9 @@
import org.jboss.forge.jmm.common.Constants;
import org.jboss.forge.jmm.common.Tags;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
import org.jboss.forge.jmm.common.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.forge.jmm.common.protocol.ScoresManager;
import org.jboss.forge.jmm.common.tools.Plugins;
import org.jboss.logging.Logger;
@@ -41,6 +43,8 @@
public abstract class Plugin {
+ public enum State { OK, FAILED };
+
/** Properties specyfic to this plugin */
protected Properties properties;
@@ -64,8 +68,14 @@
/** Cache values by default. */
protected boolean cacheValues = true;
- private Map<String,Long> cache;
+ private Map<String,Long> cachedValues;
+ /** If retryOnFail is set true and the previous state for some project was State.FAILED
+ * we give another try to get plugin value one more time at the next attempt. */
+ protected boolean retryOnFail = false;
+
+ private Map<String,State> cachedStates;
+
private Logger log = Logger.getLogger(Plugin.class);
/**
@@ -94,8 +104,10 @@
parseProperties();
if (cacheValues) {
- cache = new HashMap<String,Long>();
+ cachedValues = new HashMap<String,Long>();
}
+
+ cachedStates = new HashMap<String,State>();
}
private void parseProperties() {
@@ -117,6 +129,12 @@
if (cacheValuesString != null) {
cacheValues = Boolean.parseBoolean(cacheValuesString);
}
+
+ String retryOnFailString = properties.getProperty(
+ Tags.RETRY_ON_FAIL_PROPERTY);
+ if (retryOnFailString != null) {
+ retryOnFail = Boolean.parseBoolean(retryOnFailString);
+ }
}
/**
@@ -130,27 +148,52 @@
*/
public final long getValue(String projectId) {
- if (cacheValues && cache.containsKey(projectId)) {
+ if (cacheValues && cachedValues.containsKey(projectId)) {
- return cache.get(projectId);
+ return cachedValues.get(projectId);
}
long v = Constants.DEFAULT_PLUGIN_VALUE;
+ if (cachedStates.get(projectId).equals(State.FAILED) && !retryOnFail) {
+
+ return v;
+ }
+
try {
v = getPluginValue(projectId);
+ cachedStates.put(projectId, State.OK);
+
+ } catch (UnableToGetPluginValueException e1) {
+
+ cachedStates.put(projectId, State.FAILED);
+
+ log.debug("Unable to get plugin value for project " + id +
+ "\nCause: " + e1.getMessage());
+
+ } catch (GetPluginValueException e2) {
+
+ cachedStates.put(projectId, State.FAILED);
+
+ log.warn("Exception in plugin (getPluginValue): " + id +
+ "\nCause: " + e2.getMessage());
+
+ log.debug("Exception: ", e2);
+
} catch (Exception e) {
+ cachedStates.put(projectId, State.FAILED);
+
log.warn("Exception in plugin (getPluginValue): " + id +
- "\nCause: ", e);
+ "\nCause: ", e);
}
v = Math.max(v, minValue);
if (cacheValues) {
- cache.put(projectId, v);
+ cachedValues.put(projectId, v);
}
return v;
@@ -162,8 +205,10 @@
* @param projectId project id
* @return value computed by plugin for the project
* with the given <code>projectId</code>.
+ * @throws GetPluginValueException
*/
- protected abstract long getPluginValue(String projectId);
+ protected abstract long getPluginValue(String projectId)
+ throws GetPluginValueException, UnableToGetPluginValueException;
/** For the given project returns link associated with this plugin
@@ -258,4 +303,11 @@
return s;
}
+
+ public State getState(String projectId) {
+
+ State state = cachedStates.get(projectId);
+
+ return (state == null ? State.FAILED : state);
+ }
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/PluginValues.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/PluginValues.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/PluginValues.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -25,6 +25,8 @@
import java.io.Serializable;
import java.util.Set;
+import org.jboss.forge.jmm.common.protocol.conf.Plugin.State;
+
/**
* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com)
*/
@@ -43,4 +45,6 @@
public Set<String> getProjectIds();
+ public State getState(String projectId);
+
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/PluginValuesRemote.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/PluginValuesRemote.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-common/src/java/org/jboss/forge/jmm/common/protocol/conf/PluginValuesRemote.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -27,7 +27,7 @@
import java.util.HashMap;
import java.util.Set;
-import org.jboss.forge.jmm.common.tools.ProjectTools;
+import org.jboss.forge.jmm.common.protocol.conf.Plugin.State;
/**
* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] jboss.com)
@@ -43,6 +43,7 @@
private Map<String,Long> values = new HashMap<String,Long>();
private Map<String,Integer> rates = new HashMap<String,Integer>();
private Map<String,String> links = new HashMap<String,String>();
+ private Map<String,State> states = new HashMap<String,State>();
public void fill(PluginValues pluginValues) {
@@ -58,6 +59,7 @@
values.put(projectId, pluginValues.getValue(projectId));
rates.put(projectId, pluginValues.getRate(projectId));
links.put(projectId, pluginValues.getLink(projectId));
+ states.put(projectId, pluginValues.getState(projectId));
}
}
@@ -84,5 +86,10 @@
public Set<String> getProjectIds() {
return values.keySet();
}
+
+ public State getState(String projectId) {
+
+ return states.get(projectId);
+ }
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-portlet/src/java/org/jboss/forge/jmm/portlet/templates/MetricTemplate.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-portlet/src/java/org/jboss/forge/jmm/portlet/templates/MetricTemplate.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-portlet/src/java/org/jboss/forge/jmm/portlet/templates/MetricTemplate.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -25,6 +25,7 @@
import org.jboss.forge.jmm.common.Tags;
import org.jboss.forge.jmm.common.protocol.conf.PluginValues;
import org.jboss.forge.jmm.common.protocol.conf.PluginsValues;
+import org.jboss.forge.jmm.common.protocol.conf.Plugin.State;
import org.jboss.forge.common.XmlTools;
import org.jboss.portal.common.context.DelegateContext;
@@ -76,6 +77,16 @@
if (pluginValues != null) {
+ State state = pluginValues.getState(projectId);
+
+ if (state.equals(State.OK)) {
+
+ metricContext.next("stateOK");
+ } else {
+
+ metricContext.next("stateFailed");
+ }
+
if (showAsBoolean) {
metricContext.put("value",
@@ -93,6 +104,9 @@
metricContext.next("hasRate");
}
+ } else {
+
+ metricContext.next("stateFailed");
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol/PluginValuesEntity.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol/PluginValuesEntity.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol/PluginValuesEntity.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -42,6 +42,7 @@
import org.jboss.forge.jmm.common.protocol.conf.Plugin;
import org.jboss.forge.jmm.common.protocol.conf.PluginValues;
+import org.jboss.forge.jmm.common.protocol.conf.Plugin.State;
/**
* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com)
@@ -80,6 +81,7 @@
plugin.getValue(projectId),
plugin.getRate(projectId),
plugin.getLink(projectId),
+ plugin.getState(projectId),
this);
values.put(projectId, value);
}
@@ -159,6 +161,13 @@
return (valueEntity == null ? "" : valueEntity.getLink());
}
+ public State getState(String projectId) {
+
+ ValueEntity valueEntity = values.get(projectId);
+
+ return (valueEntity == null ? State.FAILED : valueEntity.getState());
+ }
+
@Transient
public Set<String> getProjectIds() {
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol/ValueEntity.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol/ValueEntity.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/db/protocol/ValueEntity.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -32,11 +32,13 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;
+import org.jboss.forge.jmm.common.protocol.conf.Plugin.State;
+
/**
* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com)
*/
@@ -44,7 +46,6 @@
@Table(name = "jblab_jmm_scores")
public class ValueEntity extends ScoresEntity
{
-
private static final long serialVersionUID = -6722628455147603474L;
private long id;
@@ -53,17 +54,21 @@
private long value;
private int rate;
private String link;
+
+ private State state;
+
private PluginValuesEntity pluginValues;
public ValueEntity() {}
- public ValueEntity(String projectId, long value, int rate, String link,
+ public ValueEntity(String projectId, long value, int rate, String link, State state,
PluginValuesEntity pluginValues) {
this.projectId = projectId;
this.value = value;
this.rate = rate;
this.link = link;
+ this.state = state;
this.pluginValues = pluginValues;
}
@@ -123,4 +128,13 @@
public void setPluginValues(PluginValuesEntity pluginValues) {
this.pluginValues = pluginValues;
}
+
+ @Column(name = "state")
+ public State getState() {
+ return (state == null ? State.FAILED : state);
+ }
+
+ public void setState(State state) {
+ this.state = state;
+ }
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/shotoku/protocol/PluginValuesImpl.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/shotoku/protocol/PluginValuesImpl.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/impl/shotoku/protocol/PluginValuesImpl.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -27,10 +27,9 @@
import java.util.Map;
import java.util.Set;
-import javax.persistence.Transient;
-
import org.jboss.forge.jmm.common.protocol.conf.Plugin;
import org.jboss.forge.jmm.common.protocol.conf.PluginValues;
+import org.jboss.forge.jmm.common.protocol.conf.Plugin.State;
/**
* @author Pawel Wrzeszcz (pawel.wrzeszcz [at] gmail.com)
@@ -87,4 +86,9 @@
return values.keySet();
}
+
+ public State getState(String projectId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/KosmosPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/KosmosPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/KosmosPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -22,13 +22,13 @@
package org.jboss.forge.jmm.service.plugins;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
import org.jboss.forge.jmm.common.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.forge.jmm.common.protocol.ScoresManager;
import org.jboss.forge.jmm.common.protocol.conf.Plugin;
import org.jboss.forge.jmm.common.tools.Plugins;
-import org.jboss.logging.Logger;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -56,12 +56,8 @@
*/
protected String serviceURL;
- protected Logger log;
-
public KosmosPlugin() {
super();
-
- log = Logger.getLogger(this.getClass());
projectServices = new HashMap<String,List>();
}
@@ -105,25 +101,22 @@
*/
protected abstract int getPluginSpecyficValue(Object projectMap);
-
/**
- * @return Default Plugin value, when service is not specified.
- */
- protected abstract int getPluginSpecyficDefaultValue();
-
- /**
* Returns service specyfic Maps for the given project.
*
* @param projectId
* @return service specyfic Map
+ * @throws GetPluginValueException
*/
- protected abstract List getProjectServices(String projectId);
+ protected abstract List getProjectServices(String projectId) throws GetPluginValueException;
/* (non-Javadoc)
* @see org.jboss.forge.jmm.Plugin#getValue(java.lang.String)
*/
@Override
- protected long getPluginValue(String projectId) {
+ protected long getPluginValue(String projectId)
+ throws UnableToGetPluginValueException,
+ GetPluginValueException {
if (!projectServices.containsKey(projectId)) {
projectServices.put(projectId, getProjectServices(projectId));
@@ -132,7 +125,7 @@
List projectServicesList = projectServices.get(projectId);
if (projectServicesList == null) {
- return getPluginSpecyficDefaultValue();
+ throw new UnableToGetPluginValueException("Service not specified.");
}
long value = 0;
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcBuildsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcBuildsPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcBuildsPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -31,9 +31,10 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.forge.jmm.common.protocol.conf.Plugin;
import org.jboss.forge.jmm.common.tools.ProjectTools;
-import org.jboss.logging.Logger;
/**
@@ -45,16 +46,15 @@
protected abstract String getPattern();
- protected Logger log = Logger.getLogger(CcBuildsPlugin.class);
-
@Override
- public long getPluginValue(String projectId) {
+ public long getPluginValue(String projectId)
+ throws UnableToGetPluginValueException, GetPluginValueException {
List<String> URLs = ProjectTools.getProjectCcURLs(projectId);
if (URLs == null) {
- return 0;
+ throw new UnableToGetPluginValueException("CC address not specified.");
}
long v = 0;
@@ -67,7 +67,9 @@
return v;
}
- private long get(String urlString) {
+ private long get(String urlString)
+ throws GetPluginValueException,
+ UnableToGetPluginValueException {
urlString = urlString.concat("?tab=metrics");
@@ -93,10 +95,8 @@
} catch (IOException e) {
- log.warn("Could not obtain statistics from " + urlString
- + "\nCause: " + e.getMessage());
-
- return 0;
+ throw new GetPluginValueException("Could not obtain statistics from "
+ + urlString, e);
}
string = stringBuilder.toString();
@@ -108,7 +108,8 @@
if (!matcher.find()) {
- return 0;
+ throw new UnableToGetPluginValueException("Page " + urlString +
+ " does not contain expected data.");
}
String resString = matcher.group(1);
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcErrorsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcErrorsPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcErrorsPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -37,10 +37,4 @@
CcProject ccPrj = (CcProject) ccProject;
return ccPrj.getErrors();
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -27,10 +27,9 @@
import java.net.MalformedURLException;
import org.jboss.forge.jmm.common.Tags;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
import org.jboss.forge.jmm.common.tools.ProjectTools;
import org.jboss.forge.jmm.service.plugins.KosmosPlugin;
-import org.jboss.logging.Logger;
-
import com.caucho.hessian.client.HessianProxyFactory;
import hu.midori.kosmos.model.CcProject;
@@ -49,23 +48,20 @@
protected String getKosmosServiceTag() {
return Tags.CC_SERVICE_PROPERTY;
};
-
- protected Logger log;
-
+
public CcPlugin() {
super();
-
- log = Logger.getLogger(this.getClass());
}
@Override
- protected List<CcProject> getProjectServices(String projectId) {
+ protected List<CcProject> getProjectServices(String projectId)
+ throws GetPluginValueException {
// Get project cc URLs
List<String> ccURLs = ProjectTools.getProjectCcURLs(projectId);
if ((ccURLs == null) || (ccURLs.isEmpty())) {
- return null;
+ return null;
}
// Connect to the kosmos service
@@ -75,9 +71,8 @@
try {
service = (CcService) factory.create(CcService.class, serviceURL);
} catch (MalformedURLException e) {
- log.error("Can not connect to kosmos cc service: " + serviceURL +
- "\nCause: " + e.getMessage());
- return null;
+ throw new GetPluginValueException(
+ "Can not connect to the kosmos cc service: " + serviceURL, e);
}
@@ -89,8 +84,7 @@
try {
stats.addAll(service.getProjects(ccURL));
} catch (Exception e) {
- log.warn("Can not analyze cc: " + ccURL +
- "\nCause:" + e.getMessage());
+ throw new GetPluginValueException("Can not analyze cc: " + ccURL, e);
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcTestsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcTestsPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/cc/CcTestsPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -36,11 +36,5 @@
protected int getPluginSpecyficValue(Object ccProject) {
CcProject ccPrj = (CcProject) ccProject;
return ccPrj.getTests();
- }
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
+ }
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/AddedCodeLinesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/AddedCodeLinesPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/AddedCodeLinesPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -26,7 +26,9 @@
import java.util.Properties;
import org.jboss.forge.jmm.common.Tags;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
import org.jboss.forge.jmm.common.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.forge.jmm.common.protocol.ScoresManager;
import org.jboss.forge.jmm.common.tools.Plugins;
import org.jboss.logging.Logger;
@@ -66,7 +68,8 @@
}
@Override
- protected long getPluginValue(String url, String userName, String password) {
+ protected long getPluginValue(String url, String userName, String password)
+ throws GetPluginValueException, UnableToGetPluginValueException {
log.info("Analyzing repository " + url + "...");
@@ -79,10 +82,8 @@
ret = CodeLinesEvaluator.getAddedCodeLines(url, days);
}
- ret = Math.max(ret,0); // Do not report decrease of number of lines??
+ log.info("Number of added lines of code: " + ret);
- log.info("Number of lines of code: " + ret);
-
return ret;
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesEvaluator.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesEvaluator.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesEvaluator.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -31,6 +31,8 @@
import java.util.HashMap;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.logging.Logger;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
@@ -64,12 +66,19 @@
* @param userName user's name used in authorisation
* @param password user's password used in authorisation
* @return number of code lines
+ * @throws GetPluginValueException
+ * @throws UnableToGetPluginValueException
*/
- public static long getCodeLinesNumber(String url, String userName, String password) {
+ public static long getCodeLinesNumber(String url, String userName, String password)
+ throws GetPluginValueException, UnableToGetPluginValueException {
SVNRepository repository = getRepository(url, userName, password);
- return (repository != null) ? getCodeLinesNumber(repository, "") : 0;
+ if (repository == null) {
+ throw new UnableToGetPluginValueException("Unable to get SVN repository.");
+ }
+
+ return getCodeLinesNumber(repository, "");
}
/**
@@ -97,8 +106,11 @@
*
* @param url SVN repository adress
* @return number of code lines
+ * @throws GetPluginValueException
+ * @throws UnableToGetPluginValueException
*/
- public static long getCodeLinesNumber(String url) {
+ public static long getCodeLinesNumber(String url)
+ throws GetPluginValueException, UnableToGetPluginValueException {
return getCodeLinesNumber(url, "anonymous", "anonymus");
}
@@ -122,14 +134,20 @@
* @param password user's password used in authorisation
* @param days
* @return number of code lines
+ * @throws GetPluginValueException
+ * @throws UnableToGetPluginValueException
*/
public static long getAddedCodeLines(String url, String userName,
- String password, int days) {
+ String password, int days)
+ throws GetPluginValueException, UnableToGetPluginValueException {
SVNRepository repository = getRepository(url, userName, password);
- return (repository != null) ?
- getAddedCodeLines(repository, "", days) : 0;
+ if (repository == null) {
+ throw new UnableToGetPluginValueException("Unable to get SVN repository.");
+ }
+
+ return getAddedCodeLines(repository, "", days);
}
@@ -140,8 +158,11 @@
* @param url SVN repository adress
* @param days
* @return number of code lines
+ * @throws GetPluginValueException
+ * @throws UnableToGetPluginValueException
*/
- public static long getAddedCodeLines(String url, int days) {
+ public static long getAddedCodeLines(String url, int days)
+ throws GetPluginValueException, UnableToGetPluginValueException {
return getAddedCodeLines(url, "anonymous", "anonymus", days);
}
@@ -159,12 +180,13 @@
/* Connect to svn repository */
SVNRepository repository = connect(url);
- if (repository == null)
- return null;
+ if (repository == null) {
+ return null;
+ }
/* Authentication handling */
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, password);
- repository.setAuthenticationManager(authManager);
+ repository.setAuthenticationManager(authManager);
return repository;
}
@@ -176,8 +198,9 @@
* @param repository SVN repository adress
* @param path path to SVN directory
* @return number of code lines
+ * @throws GetPluginValueException
*/
- private static long getCodeLinesNumber(SVNRepository repository, String path) {
+ private static long getCodeLinesNumber(SVNRepository repository, String path) throws GetPluginValueException {
log.debug("Analyzing " + path + ".");
@@ -201,7 +224,6 @@
cl += getCodeLinesNumber(repository, entryPath);
}
}
-
}
return cl;
@@ -213,8 +235,9 @@
* @param repository SVN repository adress
* @param filePath path to the file to analyze
* @return number of code lines
+ * @throws GetPluginValueException
*/
- private static long analyzeFile(SVNRepository repository, String filePath) {
+ private static long analyzeFile(SVNRepository repository, String filePath) throws GetPluginValueException {
long cl = 0;
@@ -225,10 +248,8 @@
try {
repository.getFile(filePath, -1, fileProperties, baos);
} catch (SVNException svne) {
- log.warn("Error while fetching the file properties: " +
- repository.getLocation().toString() + "/" + filePath +
- "\nCause:" + svne.getMessage());
- return 0;
+ throw new GetPluginValueException("Error fetching the file properties: " +
+ repository.getLocation().toString() + "/" + filePath, svne);
}
/* Get file type */
@@ -254,9 +275,11 @@
* @param repository SVN repository adress
* @param path SVN directory path
* @return Collection of directory entries
+ * @throws GetPluginValueException
*/
@SuppressWarnings("unchecked")
- private static Collection<SVNDirEntry> getDirEntries(SVNRepository repository, String path) {
+ private static Collection<SVNDirEntry> getDirEntries(SVNRepository repository, String path)
+ throws GetPluginValueException {
Map fileProperties = new HashMap();
Collection<SVNDirEntry> dirEntries = null;
@@ -264,9 +287,8 @@
try {
dirEntries = repository.getDir(path, -1, fileProperties, (Collection) null);
} catch (SVNException e) {
- log.warn("Error fetching directory entries:" +
- repository.getLocation().toString() + "/" + path +
- "\nCause: " + e.getMessage());
+ throw new GetPluginValueException("Error fetching directory entries:" +
+ repository.getLocation().toString() + "/" + path, e);
}
return dirEntries;
@@ -281,9 +303,10 @@
* @param path path to SVN directory
* @param days
* @return number of added code lines
+ * @throws GetPluginValueException
*/
private static long getAddedCodeLines(SVNRepository repository,
- String path, int days) {
+ String path, int days) throws GetPluginValueException {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, -days);
@@ -297,8 +320,8 @@
ret = getAddedCodeLines(repository, path,
fromRev, SVNRevision.HEAD);
} catch (SVNException e) {
- log.warn("Failed to evaluate added code lines." +
- "\nCause: " + e.getMessage());
+ throw new GetPluginValueException(
+ "Failed to evaluate added code lines.", e);
}
return ret;
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -25,6 +25,8 @@
import java.util.List;
import org.jboss.forge.common.projects.project.Repository;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.forge.jmm.common.protocol.conf.Plugin;
import org.jboss.forge.jmm.common.tools.ProjectTools;
@@ -43,15 +45,19 @@
* @param userName user's name used in authorisation
* @param password user's password used in authorisation
* @return value specyfit to the plugin
+ * @throws GetPluginValueException
+ * @throws UnableToGetPluginValueException
*/
- protected abstract long getPluginValue(String url, String userName, String password);
+ protected abstract long getPluginValue(String url, String userName, String password)
+ throws GetPluginValueException, UnableToGetPluginValueException;
public CodeLinesPlugin() {
super();
}
@Override
- public long getPluginValue(String projectId) {
+ public long getPluginValue(String projectId)
+ throws UnableToGetPluginValueException, GetPluginValueException {
long cl = 0;
@@ -59,7 +65,7 @@
if (repoList == null) {
- return 0;
+ throw new UnableToGetPluginValueException("Repository not specified.");
}
for (Repository repository : repoList) {
@@ -71,7 +77,8 @@
return cl;
}
- private long analyze(String url) {
+ private long analyze(String url) throws GetPluginValueException,
+ UnableToGetPluginValueException {
return getPluginValue(url, null, null);
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesTotalPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesTotalPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/CodeLinesTotalPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -22,6 +22,8 @@
package org.jboss.forge.jmm.service.plugins.codelines;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.logging.Logger;
import org.tmatesoft.svn.core.SVNException;
@@ -35,7 +37,8 @@
protected static Logger log = Logger.getLogger(CodeLinesTotalPlugin.class);
@Override
- protected long getPluginValue(String url, String userName, String password) {
+ protected long getPluginValue(String url, String userName, String password)
+ throws GetPluginValueException, UnableToGetPluginValueException {
log.info("Analyzing repository " + url + "...");
@@ -49,9 +52,8 @@
cl = CodeLinesEvaluator.getCodeLinesNumberFast(url);
} catch (SVNException e) {
- log.warn("Unable to evaluate number of code lines. URL: " + url
- + "\nCause: " + e.getMessage());
- log.debug("Error: ", e);
+ throw new GetPluginValueException(
+ "Unable to evaluate number of code lines. URL: " + url, e);
}
log.info("Number of lines of code: " + cl);
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/SlowCodeLinesTotalPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/SlowCodeLinesTotalPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/codelines/SlowCodeLinesTotalPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -22,6 +22,9 @@
package org.jboss.forge.jmm.service.plugins.codelines;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
+
/**
* @author Pawel Wrzeszcz
* Plugin returns total number of lines of code in project svn repository.
@@ -30,7 +33,8 @@
public class SlowCodeLinesTotalPlugin extends CodeLinesPlugin {
@Override
- protected long getPluginValue(String url, String userName, String password) {
+ protected long getPluginValue(String url, String userName, String password)
+ throws GetPluginValueException, UnableToGetPluginValueException {
if ((userName != null) && (password != null)) {
return CodeLinesEvaluator.getCodeLinesNumber(url, userName, password);
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/ClosedIssuesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/ClosedIssuesPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/ClosedIssuesPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -38,10 +38,5 @@
JiraProject jp = (JiraProject) jiraProject;
return jp.getClosedIssues();
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/JiraPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/JiraPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/JiraPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -27,6 +27,7 @@
import org.jboss.forge.common.projects.project.IssueTracker;
import org.jboss.forge.jmm.common.Tags;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
import org.jboss.forge.jmm.common.tools.ProjectTools;
import org.jboss.forge.jmm.service.plugins.KosmosPlugin;
import org.jboss.logging.Logger;
@@ -58,7 +59,7 @@
}
@Override
- protected List<JiraProject> getProjectServices(String projectId) {
+ protected List<JiraProject> getProjectServices(String projectId) throws GetPluginValueException {
// Get project jira URL
String jiraURL = getJiraURL(projectId);
@@ -74,9 +75,8 @@
try {
service = (JiraService) factory.create(JiraService.class, serviceURL);
} catch (MalformedURLException e) {
- log.error("Can not connect to kosmos jira service: " + serviceURL
- + "\nCause: " + e.getMessage());
- return null;
+ throw new GetPluginValueException(
+ "Can not connect to the kosmos jira service: " + serviceURL, e);
}
// Get map with jira statistics
@@ -84,16 +84,14 @@
try {
projects = service.getProjects(jiraURL);
} catch (Exception e) {
- log.error("Can not analyze jira: " + jiraURL +
- "\nCause: " + e.getMessage());
- return null;
+ throw new GetPluginValueException("Can not analyze jira: " + jiraURL, e);
}
return projects;
}
- private String getJiraURL(String projectId) {
+ private static String getJiraURL(String projectId) {
IssueTracker it = ProjectTools.getProjectJiraIssueTracker(projectId);
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/OpenIssuesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/OpenIssuesPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/OpenIssuesPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -38,10 +38,4 @@
JiraProject jp = (JiraProject) jiraProject;
return jp.getOpenIssues();
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/ResolvedIssuesPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/ResolvedIssuesPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/jira/ResolvedIssuesPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -38,10 +38,4 @@
JiraProject jp = (JiraProject) jiraProject;
return jp.getResolvedIssues();
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/AddPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/AddPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/AddPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -29,12 +29,8 @@
public class AddPlugin extends MathPlugin {
@Override
- public long getPluginValue(String projectId) {
+ public long getPluginSpecyficValue(String projectId) {
- long v1 = plugin1.getValue(projectId);
- long v2 = plugin2.getValue(projectId);
-
return (v1 + v2);
-
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/DivPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/DivPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/DivPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -22,6 +22,8 @@
package org.jboss.forge.jmm.service.plugins.math;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
+
/**
* @author Pawel Wrzeszcz (pawel . wrzeszcz [at] jboss . com)
*/
@@ -29,17 +31,13 @@
public class DivPlugin extends MathPlugin {
@Override
- public long getPluginValue(String projectId) {
+ public long getPluginSpecyficValue(String projectId)
+ throws UnableToGetPluginValueException {
- long v2 = plugin2.getValue(projectId);
-
if (v2 == 0) {
- return 0;
+ throw new UnableToGetPluginValueException("Division by zero.");
}
- long v1 = plugin1.getValue(projectId);
-
return (v1 / v2);
-
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/LastNDaysPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/LastNDaysPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/LastNDaysPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -29,6 +29,7 @@
import org.jboss.forge.jmm.common.Tags;
import org.jboss.forge.jmm.common.exceptions.InvalidPluginPropertiesException;
import org.jboss.forge.jmm.common.exceptions.ScoresException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.forge.jmm.common.protocol.ScoresManager;
import org.jboss.forge.jmm.common.protocol.conf.Plugin;
import org.jboss.forge.jmm.common.tools.Plugins;
@@ -77,9 +78,15 @@
}
@Override
- public long getPluginValue(String projectId) {
+ public long getPluginValue(String projectId) throws UnableToGetPluginValueException {
long currentValue = insidePlugin.getValue(projectId);
+
+ if (insidePlugin.getState(projectId).equals(State.FAILED)) {
+ throw new UnableToGetPluginValueException(
+ "Failed to get current value for plugin " + insidePlugin.getId() + ".");
+ }
+
long prevValue = 0;
Calendar now = Calendar.getInstance();
@@ -91,7 +98,7 @@
prevValue = scoresManager.getValue(
insidePlugin.getId(), projectId, cal, now);
} catch (ScoresException e) {
- return 0;
+ throw new UnableToGetPluginValueException(e);
}
return (currentValue - prevValue);
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/MathPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/MathPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/MathPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -26,6 +26,7 @@
import java.util.Properties;
import org.jboss.forge.jmm.common.exceptions.InvalidPluginPropertiesException;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.forge.jmm.common.protocol.ScoresManager;
import org.jboss.forge.jmm.common.protocol.conf.Plugin;
import org.jboss.forge.jmm.common.tools.Plugins;
@@ -39,6 +40,9 @@
protected Plugin plugin1;
protected Plugin plugin2;
+ protected long v1;
+ protected long v2;
+
@Override
public void init(String id, String portalName, List<String> projectIds,
Plugins plugins, Properties properties, ScoresManager scoresManager)
@@ -72,4 +76,30 @@
properties, scoresManager);
}
+
+ public long getPluginValue(String projectId) throws UnableToGetPluginValueException {
+
+ v1 = plugin1.getValue(projectId);
+ v2 = plugin2.getValue(projectId);
+
+ assertValueOK(projectId, plugin1);
+ assertValueOK(projectId, plugin2);
+
+ return getPluginSpecyficValue(projectId);
+ }
+
+
+ private static void assertValueOK(String projectId, Plugin plugin)
+ throws UnableToGetPluginValueException {
+
+ if (plugin.getState(projectId).equals(State.FAILED)) {
+ throw new UnableToGetPluginValueException(
+ "Failed to get value for plugin " + plugin.getId() + ".");
+ }
+ }
+
+
+ protected abstract long getPluginSpecyficValue(String projectId)
+ throws UnableToGetPluginValueException;
+
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/MulPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/MulPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/math/MulPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -29,12 +29,8 @@
public class MulPlugin extends MathPlugin {
@Override
- public long getPluginValue(String projectId) {
+ public long getPluginSpecyficValue(String projectId) {
- long v1 = plugin1.getValue(projectId);
- long v2 = plugin2.getValue(projectId);
-
return (v1 * v2);
-
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/productization/DownloadsPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/productization/DownloadsPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/productization/DownloadsPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -23,6 +23,7 @@
package org.jboss.forge.jmm.service.plugins.productization;
+import org.jboss.forge.jmm.common.exceptions.UnableToGetPluginValueException;
import org.jboss.forge.jmm.common.protocol.conf.Plugin;
import org.jboss.forge.jmm.common.tools.ProjectTools;
@@ -39,9 +40,15 @@
super();
}
- public long getPluginValue(String projectId) {
+ public long getPluginValue(String projectId) throws UnableToGetPluginValueException {
- return ProjectTools.getOverallDownloadsForProject(projectId, portalName);
+ long downloads = ProjectTools.getOverallDownloadsForProject(projectId, portalName);
+
+ if (downloads == 0) {
+ throw new UnableToGetPluginValueException("Could not get number of downloads (0).");
+ }
+
+ return downloads;
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsLast31DaysPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsLast31DaysPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsLast31DaysPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -40,10 +40,4 @@
SvnRepository repo = (SvnRepository) repository;
return repo.getCommitsLast31Days();
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsLast7DaysPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsLast7DaysPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsLast7DaysPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -40,10 +40,4 @@
SvnRepository repo = (SvnRepository) repository;
return repo.getCommitsLast7Days();
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsTodayPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsTodayPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsTodayPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -40,10 +40,4 @@
SvnRepository repo = (SvnRepository) repository;
return repo.getCommitsToday();
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsTotalPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsTotalPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/CommitsTotalPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -40,10 +40,4 @@
SvnRepository repo = (SvnRepository) repository;
return repo.getCommitsTotal();
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/RevisionPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/RevisionPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/RevisionPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -42,10 +42,4 @@
return Long.valueOf(repo.getRevision()).intValue();
//TODO possible out of range
}
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
}
\ No newline at end of file
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/SvnPlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/SvnPlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/SvnPlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -27,9 +27,9 @@
import org.jboss.forge.common.projects.project.Repository;
import org.jboss.forge.jmm.common.Tags;
+import org.jboss.forge.jmm.common.exceptions.GetPluginValueException;
import org.jboss.forge.jmm.common.tools.ProjectTools;
import org.jboss.forge.jmm.service.plugins.KosmosPlugin;
-import org.jboss.logging.Logger;
import com.caucho.hessian.client.HessianProxyFactory;
@@ -49,16 +49,13 @@
return Tags.SVN_SERVICE_PROPERTY;
};
- protected Logger log;
-
public SvnPlugin() {
super();
-
- log = Logger.getLogger(this.getClass());
}
@Override
- protected List<SvnRepository> getProjectServices(String projectId) {
+ protected List<SvnRepository> getProjectServices(String projectId)
+ throws GetPluginValueException {
// Get project repository URL
String repoURL = getRepoURL(projectId);
@@ -74,9 +71,8 @@
try {
service = (SvnService) factory.create(SvnService.class, serviceURL);
} catch (MalformedURLException e) {
- log.error("Can not connect to the kosmos svn service: " + serviceURL
- + "\nCause: " + e.getMessage());
- return null;
+ throw new GetPluginValueException(
+ "Can not connect to the kosmos svn service: " + serviceURL, e);
}
// Get map with repository statistics
@@ -84,10 +80,7 @@
try {
repositories = service.getRepositories(repoURL);
} catch (Exception e) {
- log.error("Can not analyze repo: " + repoURL +
- "\nCause: " + e.getMessage());
- e.printStackTrace();
- return null;
+ throw new GetPluginValueException("Can not analyze repository: " + repoURL, e);
}
return repositories;
Modified: labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/TotalRepoSizePlugin.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/TotalRepoSizePlugin.java 2006-12-22 19:41:29 UTC (rev 8563)
+++ labs/jbosslabs/trunk/portal-extensions/jmm/jmm-service/src/java/org/jboss/forge/jmm/service/plugins/svn/TotalRepoSizePlugin.java 2006-12-22 21:28:58 UTC (rev 8564)
@@ -39,11 +39,5 @@
protected int getPluginSpecyficValue(Object repository) {
SvnRepository repo = (SvnRepository) repository;
return repo.getTotalFileSize();
- }
-
- @Override
- protected int getPluginSpecyficDefaultValue() {
- return 0;
- }
-
+ }
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list