diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-06-10 15:24:57 +0200 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-06-10 15:24:57 +0200 |
commit | 78e9b96a51e2ef677a4eb8b801e18248d7e32283 (patch) | |
tree | e0bae2cb0f36df7ac10edddcb929683437abc2c1 /sonar-plugin-api | |
parent | 3203b81516eb93052a05b74c6e0a5ddc7f1977ca (diff) | |
parent | 231d8aeceb89848a8099f1d516f85d76106f3fef (diff) | |
download | sonarqube-78e9b96a51e2ef677a4eb8b801e18248d7e32283.tar.gz sonarqube-78e9b96a51e2ef677a4eb8b801e18248d7e32283.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'sonar-plugin-api')
21 files changed, 0 insertions, 1991 deletions
diff --git a/sonar-plugin-api/pom.xml b/sonar-plugin-api/pom.xml index f6ca09bc860..d6d030387f7 100644 --- a/sonar-plugin-api/pom.xml +++ b/sonar-plugin-api/pom.xml @@ -10,19 +10,6 @@ <packaging>jar</packaging> <name>Sonar :: Plugin API</name> <build> - <resources> - <!-- sources of Sonar GWT library --> - <resource> - <directory>src/main/java</directory> - <includes> - <include>**/org/sonar/api/web/gwt/**/*</include> - </includes> - </resource> - <resource> - <directory>src/main/resources</directory> - </resource> - </resources> - <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -137,16 +124,6 @@ <artifactId>xpp3</artifactId> </dependency> <dependency> - <groupId>com.google.gwt</groupId> - <artifactId>gwt-user</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.gwt</groupId> - <artifactId>gwt-incubator</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.codehaus.woodstox</groupId> <artifactId>woodstox-core-lgpl</artifactId> </dependency> diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractPage.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractPage.java deleted file mode 100644 index 08ecfa30815..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractPage.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; - -/** - * @deprecated since 2.0, use the lib sonar-gwt-api - */ -@Deprecated -public abstract class AbstractPage implements EntryPoint { - - protected void displayView(Widget widget) { - Element loading = DOM.getElementById("loading"); - if (loading != null) { - DOM.removeChild(getRootPanel().getElement(), loading); - } - getRootPanel().add(widget); - } - - protected RootPanel getRootPanel() { - RootPanel rootPanel = RootPanel.get("gwtpage-" + GWT.getModuleName()); - if (rootPanel == null) { - rootPanel = RootPanel.get("gwtpage"); - } - return rootPanel; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/ResourceDictionary.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/ResourceDictionary.java deleted file mode 100644 index ea08ac8c8dd..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/ResourceDictionary.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client; - -import com.google.gwt.i18n.client.Dictionary; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public final class ResourceDictionary { - - public final static String CONF_PERMALINK_BASE = "permalink_url_base"; - public final static String CONF_RESOURCE_KEY = "resource_key"; - public final static String CONF_V_RESOURCE_KEY = "viewer_resource_key"; - public final static String CONF_V_PLUGIN_KEY = "viewer_plugin_key"; - public final static String CONF_V_METRIC_KEY = "metric"; - - private ResourceDictionary() { - } - - public static String getPermaLinkURLBase() { - return Utils.getConfiguration(CONF_PERMALINK_BASE); - } - - public static String getResourceKey() { - return Utils.getConfiguration(CONF_RESOURCE_KEY); - } - - public static String getViewerResourceKey() { - return Utils.getConfiguration(CONF_V_RESOURCE_KEY); - } - - public static String getViewerPluginKey() { - return Utils.getConfiguration(CONF_V_PLUGIN_KEY); - } - - public static String getViewerMetricKey() { - return Utils.getConfiguration(CONF_V_METRIC_KEY); - } - - public static Dictionary getResourceViewers() { - return Dictionary.getDictionary("resource_viewers"); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/Utils.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/Utils.java deleted file mode 100644 index 97f6b9d6a8f..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/Utils.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client; - -import com.google.gwt.i18n.client.Dictionary; -import com.google.gwt.i18n.client.NumberFormat; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.Window; -import org.sonar.api.web.gwt.client.webservices.Resource; - -import java.util.Set; - -/** - * A class of web utility - * - * @since 1.10 - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public final class Utils { - private Utils() { - } - - public static String getConfiguration(String key) { - return getConfiguration(key, null); - } - - public static String getConfiguration(String key, String defaultValue) { - String result = getDictionaryEntry("config", key); - if (result == null) { - result = defaultValue; - } - return result; - } - - public static native void setConfiguration(String key, String val) /*-{ - $wnd.config[key] = val; - }-*/; - - public static String getRequestParameter(String key) { - return getDictionaryEntry("request_parameters", key); - } - - public static Set<String> getConfigurationKeys() { - return getDictionaryKeys("config"); - } - - public static Set<String> getRequestParameterNames() { - return getDictionaryKeys("request_parameters"); - } - - private static String getDictionaryEntry(String dictionaryName, String key) { - try { - Dictionary dic = Dictionary.getDictionary(dictionaryName); - if (dic != null) { - return dic.get(key); - } - return null; - - } catch (Exception e) { - return null; - } - } - - private static Set<String> getDictionaryKeys(String dictionaryName) { - Dictionary dic = Dictionary.getDictionary(dictionaryName); - if (dic != null) { - return dic.keySet(); - } - return null; - } - - public static String widgetGWTIdJSEncode(String widgetGWTId) { - return widgetGWTId.replace('.', '_'); - } - - public static String getServerUrl() { - return getConfiguration("sonar_url"); - } - - public static String getServerApiUrl() { - return getServerUrl() + "/api"; - } - - public static String escapeHtml(String maybeHtml) { - final Element div = DOM.createDiv(); - DOM.setInnerText(div, maybeHtml); - return DOM.getInnerHTML(div); - } - - public static String formatPercent(String percentage) { - return percentage == null || percentage.equals("") ? "" : formatPercent(new Double(percentage)); - } - - public static String formatPercent(double percentage) { - return NumberFormat.getFormat("0.0").format(percentage) + "%"; - } - - public static String formatNumber(String number) { - return number == null || number.equals("") ? "" : formatNumber(new Double(number)); - } - - public static String formatNumber(double number) { - return NumberFormat.getDecimalFormat().format(number); - } - - public static native void showError(String message) /*-{ - $wnd.error(message); - }-*/; - - public static native void showWarning(String message) /*-{ - $wnd.warning(message); - }-*/; - - public static native void showInfo(String message) /*-{ - $wnd.info(message); - }-*/; - - /** - * Display the resource in a popup. - * - * @param resource the resource to display, not null - * @param metricKey the metric to highlight (optional : can be null) - */ - public static void openResourcePopup(final Resource resource, final String metricKey) { - String url = Utils.getServerUrl() + "/resource/index/" + resource.getId(); - if (metricKey != null) { - url += "?" + ResourceDictionary.CONF_V_METRIC_KEY + "=" + metricKey; - } - Window.open(url, "resource", "height=800,width=900,scrollbars=1,resizable=1"); - } - - public static String getUrlToRuleDescription(final String ruleKey, final boolean showLayout) { - return Utils.getServerUrl() + "/rules/show/" + ruleKey + "?layout=" + showLayout; - } -} - - diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/AbstractResourceQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/AbstractResourceQuery.java deleted file mode 100644 index 07873b3eff2..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/AbstractResourceQuery.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -/** - * @deprecated since 2.5 - */ -@Deprecated -public abstract class AbstractResourceQuery<R extends ResponsePOJO> extends Query<R> { - - private String resourceKey; - - protected AbstractResourceQuery(String resourceKey) { - super(); - this.resourceKey = resourceKey; - } - - public String getResourceKey() { - return resourceKey; - } - - public void setResourceKey(String resourceKey) { - this.resourceKey = resourceKey; - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/BaseQueryCallback.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/BaseQueryCallback.java deleted file mode 100644 index bd997d099b9..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/BaseQueryCallback.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import org.sonar.api.web.gwt.client.Utils; -import org.sonar.api.web.gwt.client.widgets.LoadingLabel; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public abstract class BaseQueryCallback<P extends ResponsePOJO> implements QueryCallBack<P> { - - private LoadingLabel loading; - - public BaseQueryCallback() { - this(null); - } - - public BaseQueryCallback(LoadingLabel loading) { - super(); - this.loading = loading; - } - - public void onError(int errorCode, String errorMessage) { - Utils.showError("Error received from server : " + errorCode + " - " + errorMessage); - if (loading != null) { - loading.removeFromParent(); - } - } - - public void onTimeout() { - Utils.showWarning("JSON query response timeout"); - if (loading != null) { - loading.removeFromParent(); - } - } - -}
\ No newline at end of file diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JSONHandlerDispatcher.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JSONHandlerDispatcher.java deleted file mode 100644 index 0ff29c002dc..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JSONHandlerDispatcher.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import com.google.gwt.core.client.JavaScriptObject; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public abstract class JSONHandlerDispatcher<P extends ResponsePOJO> implements JsonUtils.JSONHandler { - - private QueryCallBack<P> callBack; - - public JSONHandlerDispatcher(QueryCallBack<P> callBack) { - super(); - this.callBack = callBack; - } - - public abstract P parseResponse(JavaScriptObject obj); - - public void onError(int errorCode, String errorMessage) { - callBack.onError(errorCode, errorMessage); - } - - public void onResponse(JavaScriptObject obj) { - P responseObj = parseResponse(obj); - callBack.onResponse(responseObj, obj); - } - - public void onTimeout() { - callBack.onTimeout(); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JsonUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JsonUtils.java deleted file mode 100644 index a2d6552a254..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JsonUtils.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import java.util.Date; - -import com.google.gwt.core.client.JavaScriptException; -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.http.client.URL; -import com.google.gwt.i18n.client.DateTimeFormat; -import com.google.gwt.json.client.JSONArray; -import com.google.gwt.json.client.JSONBoolean; -import com.google.gwt.json.client.JSONNumber; -import com.google.gwt.json.client.JSONObject; -import com.google.gwt.json.client.JSONString; -import com.google.gwt.json.client.JSONValue; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public final class JsonUtils { - private static int requestId = 0; - - private JsonUtils() { - - } - - public interface JSONHandler { - void onResponse(JavaScriptObject obj); - - void onTimeout(); - - void onError(int errorCode, String errorMessage); - } - - public static void requestJson(String url, JSONHandler handler) { - if (!url.endsWith("&") && !url.endsWith("?")) { - url += "&"; - } - if (!url.contains("format=json")) { - url += "format=json&"; - } - if (!url.contains("callback=")) { - //IMPORTANT : the url should ended with ?callback= or &callback= for JSONP calls - url += "callback="; - } - makeJSONRequest(requestId++, URL.encode(url), handler); - } - - public static native void makeJSONRequest(int requestId, String url, JSONHandler handler) /*-{ - var callback = "callback" + requestId; - - // create SCRIPT tag, and set SRC attribute equal to JSON feed URL + callback function name - var script = document.createElement("script"); - script.setAttribute("src", url+callback); - script.setAttribute("type", "text/javascript"); - - window[callback] = function(jsonObj) { - @org.sonar.api.web.gwt.client.webservices.JsonUtils::dispatchJSON(Lcom/google/gwt/core/client/JavaScriptObject;Lorg/sonar/api/web/gwt/client/webservices/JsonUtils$JSONHandler;)(jsonObj, handler); - window[callback + "done"] = true; - } - - setTimeout(function() { - if (!window[callback + "done"]) { - handler.@org.sonar.api.web.gwt.client.webservices.JsonUtils.JSONHandler::onTimeout(); - } - - // cleanup - document.body.removeChild(script); - if (window[callback]) { - delete window[callback]; - } - if (window[callback + "done"]) { - delete window[callback + "done"]; - } - }, 120000); - - document.body.appendChild(script); - }-*/; - - public static void dispatchJSON(JavaScriptObject jsonObj, JSONHandler handler) { - JSONObject obj = new JSONObject(jsonObj); - if (obj.isObject() != null) { - if (obj.containsKey("err_code")) { - handler.onError(new Double(obj.get("err_code").isNumber().doubleValue()).intValue(), - obj.get("err_msg").isString().stringValue()); - return; - } - } - handler.onResponse(jsonObj); - } - - public static String getString(JSONObject json, String field) { - JSONValue jsonValue; - JSONString jsonString; - if ((jsonValue = json.get(field)) == null) { - return null; - } - if ((jsonString = jsonValue.isString()) == null) { - JSONNumber jsonNumber = jsonValue.isNumber(); - return jsonNumber != null ? jsonNumber.toString() : null; - } - return jsonString.stringValue(); - } - - public static Date getDate(JSONObject json, String field) { - DateTimeFormat frmt = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ssZ"); - String date = getString(json, field); - if (date!=null && date.endsWith("Z") && date.length()>2) { - // see SONAR-1182 - date = date.substring(0, date.length()-2) + "+00:00"; - } - return frmt.parse(date); - } - - public static Boolean getBoolean(JSONObject json, String field) { - JSONValue jsonValue; - JSONBoolean jsonBoolean; - if ((jsonValue = json.get(field)) == null) { - return null; - } - if ((jsonBoolean = jsonValue.isBoolean()) == null) { - return null; - } - return jsonBoolean.booleanValue(); - } - - public static Double getDouble(JSONObject json, String field) { - JSONValue jsonValue; - JSONNumber jsonNumber; - if ((jsonValue = json.get(field)) == null) { - return null; - } - if ((jsonNumber = jsonValue.isNumber()) == null) { - return null; - } - return jsonNumber.doubleValue(); - } - - public static Integer getInteger(JSONObject json, String field) { - final Double d = getDouble(json, field); - if (d != null) { - return d.intValue(); - } - return null; - } - - public static JSONObject getArray(JSONValue json, int i) { - if (json instanceof JSONArray) { - return ((JSONArray) json).get(i).isObject(); - } - if (json instanceof JSONObject) { - return ((JSONObject) json).get(Integer.toString(i)).isObject(); - } - throw new JavaScriptException("Not implemented"); - } - - public static int getArraySize(JSONValue array) { - if (array instanceof JSONArray) { - return ((JSONArray) array).size(); - } - if (array instanceof JSONObject) { - return ((JSONObject) array).size(); - } - throw new JavaScriptException("Not implemented"); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java deleted file mode 100644 index 51fa83584cb..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import java.util.Date; -import java.util.Map; -import java.util.TreeMap; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.Measure} instead. - */ -@Deprecated -public class Measure { - private String metric; - private String metricName; - private Double value; - private String formattedValue; - private String data; - - private String ruleKey; - private String ruleName; - private String rulePriority; - - private Date date; - - public Measure() { - } - - public Measure(String metric, Double value, String formattedValue) { - this.metric = metric; - this.value = value; - this.formattedValue = formattedValue; - } - - public String getMetric() { - return metric; - } - - public void setMetric(String metric) { - this.metric = metric; - } - - public Double getValue() { - return value; - } - - public void setValue(Double value) { - this.value = value; - } - - public String getFormattedValue() { - return formattedValue; - } - - public void setFormattedValue(String formattedValue) { - this.formattedValue = formattedValue; - } - - public String getData() { - return data; - } - - public Map<String, String> getDataAsMap() { - Map<String, String> map = new TreeMap<String, String>(); - if (data != null) { - String[] strings = data.split(";"); - for (String string : strings) { - String[] keyValue = string.split("="); - map.put(keyValue[0], keyValue[1]); - } - } - return map; - - } - - public void setData(String data) { - this.data = data; - } - - public String getMetricName() { - return metricName; - } - - public void setMetricName(String metricName) { - this.metricName = metricName; - } - - public String getRuleKey() { - return ruleKey; - } - - public void setRuleKey(String s) { - this.ruleKey = s; - } - - public String getRuleName() { - return ruleName; - } - - public void setRuleName(String ruleName) { - this.ruleName = ruleName; - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public String getRuleCategory() { - return null; - } - - public String getRulePriority() { - return rulePriority; - } - - public void setRulePriority(String rulePriority) { - this.rulePriority = rulePriority; - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - @Override - public String toString() { - return "Measure{" + - "metric='" + metric + '\'' + - ", metric_name='" + metricName + '\'' + - ", val='" + value + '\'' + - ", f_val='" + formattedValue + '\'' + - '}'; - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/MetricsQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/MetricsQuery.java deleted file mode 100644 index 628dc3daf23..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/MetricsQuery.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.json.client.JSONArray; -import com.google.gwt.json.client.JSONObject; -import org.sonar.api.web.gwt.client.Utils; -import org.sonar.api.web.gwt.client.webservices.WSMetrics.MetricsList; - -import java.util.ArrayList; -import java.util.List; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.MetricQuery} instead. - */ -@Deprecated -public final class MetricsQuery extends Query<MetricsList> { - - private Boolean userManaged; - private List<WSMetrics.Metric.ValueType> excludedTypes = new ArrayList<WSMetrics.Metric.ValueType>(); - - public static MetricsQuery get() { - return new MetricsQuery(); - } - - private MetricsQuery() { - super(); - } - - public Boolean isUserManaged() { - return userManaged; - } - - public MetricsQuery setUserManaged(Boolean userManaged) { - this.userManaged = userManaged; - return this; - } - - public MetricsQuery excludeTypes(WSMetrics.Metric.ValueType... types) { - for (WSMetrics.Metric.ValueType valueType : types) { - excludedTypes.add(valueType); - } - return this; - } - - @Override - public String toString() { - return Utils.getServerApiUrl() + "/metrics?"; - } - - @Override - public void execute(QueryCallBack<MetricsList> callback) { - JsonUtils.requestJson(this.toString(), new JSONHandlerDispatcher<MetricsList>(callback) { - @Override - public MetricsList parseResponse(JavaScriptObject obj) { - return parseMetrics(obj); - } - }); - } - - private MetricsList parseMetrics(JavaScriptObject json) { - JSONArray array = new JSONArray(json); - MetricsList list = new MetricsList(); - for (int i = 0; i < array.size(); i++) { - JSONObject jsStock = array.get(i).isObject(); - if (jsStock != null) { - WSMetrics.Metric m = parseMetric(jsStock); - boolean skip = (isUserManaged() != null && (!isUserManaged() && m.isUserManaged())) || excludedTypes.contains(m.getType()); - if (!skip) { - list.getMetrics().add(m); - } - } - } - return list; - } - - private WSMetrics.Metric parseMetric(JSONObject json) { - String key = JsonUtils.getString(json, "key"); - String name = JsonUtils.getString(json, "name"); - String description = JsonUtils.getString(json, "description"); - String domain = JsonUtils.getString(json, "domain"); - String type = JsonUtils.getString(json, "val_type"); - boolean qualitative = JsonUtils.getBoolean(json, "qualitative"); - boolean userManaged = JsonUtils.getBoolean(json, "user_managed"); - Integer direction = JsonUtils.getInteger(json, "direction"); - return new WSMetrics.Metric(key, name, description, domain, qualitative, userManaged, direction, - WSMetrics.Metric.ValueType.valueOf(type)); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Query.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Query.java deleted file mode 100644 index 7bbfacc2a2c..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Query.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public abstract class Query<R extends ResponsePOJO> { - - public abstract void execute(final QueryCallBack<R> callback); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/QueryCallBack.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/QueryCallBack.java deleted file mode 100644 index 4f441b2be5b..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/QueryCallBack.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import com.google.gwt.core.client.JavaScriptObject; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public interface QueryCallBack<RESPONSE_POJO extends ResponsePOJO> { - - void onResponse(RESPONSE_POJO response, JavaScriptObject jsonRawResponse); - - void onTimeout(); - - void onError(int errorCode, String errorMessage); - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resource.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resource.java deleted file mode 100644 index 17006192956..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resource.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import java.util.List; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.Resource} instead. - */ -@Deprecated -public class Resource extends ResponsePOJO { - public static final String SCOPE_SET = "PRJ"; - public static final String SCOPE_SPACE = "DIR"; - public static final String SCOPE_ENTITY = "FIL"; - - @Deprecated - public static final String SCOPE_PROJECT = SCOPE_SET; - @Deprecated - public static final String SCOPE_DIRECTORY = SCOPE_SPACE; - @Deprecated - public static final String SCOPE_FILE = SCOPE_ENTITY; - - public static final String QUALIFIER_PROJECT = "TRK"; - public static final String QUALIFIER_MODULE = "BRC"; - @Deprecated - public static final String QUALIFIER_PROJECT_TRUNK = QUALIFIER_PROJECT; - @Deprecated - public static final String QUALIFIER_PROJECT_BRANCH = QUALIFIER_MODULE; - public static final String QUALIFIER_PACKAGE = "PAC"; - public static final String QUALIFIER_DIRECTORY = "DIR"; - public static final String QUALIFIER_FILE = "FIL"; - public static final String QUALIFIER_CLASS = "CLA"; - public static final String QUALIFIER_UNIT_TEST = "UTS"; - - private Integer id; - private String key; - private String name; - private String longName; - private String qualifier; - private String scope; - private String language; - private Integer copy; - private List<Measure> measures; - - public Resource() { - } - - public Resource(Integer id, String key, String name, String scope, String qualifier, String language, Integer copy, List<Measure> measures) { - this.id = id; - this.key = key; - this.name = name; - this.qualifier = qualifier; - this.scope = scope; - this.language = language; - this.measures = measures; - this.copy = copy; - } - - public Integer getId() { - return id; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getName() { - return name; - } - - public String getName(boolean longFormatIfDefined) { - if (longFormatIfDefined && longName != null && !"".equals(longName)) { - return longName; - } - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getLongName() { - return longName; - } - - public void setLongName(String longName) { - this.longName = longName; - } - - public String getQualifier() { - return qualifier; - } - - public void setQualifier(String qualifier) { - this.qualifier = qualifier; - } - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public Integer getCopy() { - return copy; - } - - public void setCopy(Integer copy) { - this.copy = copy; - } - - public List<Measure> getMeasures() { - return measures; - } - - public Measure getMeasure(WSMetrics.Metric metric) { - if (measures != null) { - for (Measure measure : measures) { - if (measure.getMetric().equals(metric.getKey())) { - return measure; - } - } - } - return null; - } - - public boolean hasMeasure(WSMetrics.Metric metric) { - return getMeasure(metric) != null; - } - - public String getMeasureFormattedValue(WSMetrics.Metric metric, String defaultValue) { - Measure measure = getMeasure(metric); - if (measure != null) { - return measure.getFormattedValue(); - } - return defaultValue; - } - - public void setMeasures(List<Measure> measures) { - this.measures = measures; - } - - public boolean matchesKey(String resourceKey) { - return resourceKey != null && (getId().toString().equals(resourceKey) || getKey().equals(resourceKey)); - } - - @Override - public String toString() { - return "Resource{" + - "id='" + id + '\'' + - ", key='" + key + '\'' + - ", name='" + name + '\'' + - ", longName='" + longName + '\'' + - ", scope='" + scope + '\'' + - ", qualifier='" + qualifier + '\'' + - ", language='" + language + '\'' + - ", measures=" + measures + - '}'; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resources.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resources.java deleted file mode 100644 index 56cbfd9972c..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resources.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import java.util.List; - -/** - * @deprecated since 2.5 - */ -@Deprecated -public class Resources extends ResponsePOJO { - - private List<Resource> resources; - - public Resources(List<Resource> resources) { - super(); - this.resources = resources; - } - - public List<Resource> getResources() { - return resources; - } - - public Resource firstResource() { - return resources.size() > 0 ? resources.get(0) : null; - } - - public boolean onceContainsMeasure(WSMetrics.Metric metric) { - for (Resource resource : resources) { - if (resource.getMeasure(metric) != null) { - return true; - } - } - return false; - } - - public boolean allContainsMeasure(WSMetrics.Metric metric) { - for (Resource resource : resources) { - if (resource.getMeasure(metric) == null) { - return false; - } - } - return true; - } - - public boolean isEmpty() { - return resources == null || resources.isEmpty(); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java deleted file mode 100644 index b984bfe0383..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.json.client.JSONArray; -import com.google.gwt.json.client.JSONObject; -import com.google.gwt.json.client.JSONValue; -import org.sonar.api.web.gwt.client.Utils; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.ResourceQuery} instead - */ -@Deprecated -public final class ResourcesQuery extends AbstractResourceQuery<Resources> { - - public final static int DEPTH_UNLIMITED = -1; - - private Integer depth; - private Integer limit; - private String scopes; - private String qualifiers; - private String metrics; - private String rules; - private String rulePriorities; - private boolean verbose = false; - - /** - * Alias for build() - */ - public static ResourcesQuery get(String resourceKey) { - return new ResourcesQuery(resourceKey); - } - - public static ResourcesQuery build(String resourceKey) { - return new ResourcesQuery(resourceKey); - } - - public static ResourcesQuery build() { - return new ResourcesQuery(null); - } - - private ResourcesQuery(String resourceKey) { - super(resourceKey); - } - - public ResourcesQuery setDepth(Integer depth) { - this.depth = depth; - return this; - } - - public ResourcesQuery setRules(String s) { - this.rules = s; - return this; - } - - public ResourcesQuery filterOnRules(boolean b) { - return setRules(b ? "true" : "false"); - } - - public ResourcesQuery filterOnRulePriorities(boolean b) { - return setRulePriorities(b ? "true" : "false"); - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public ResourcesQuery filterOnRuleCategories(boolean b) { - return this; - } - - public ResourcesQuery setRulePriorities(String s) { - this.rulePriorities = s; - return this; - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public ResourcesQuery setRuleCategories(String s) { - return this; - } - - public ResourcesQuery setLimit(Integer limit) { - this.limit = limit; - return this; - } - - public ResourcesQuery setScopes(String scopes) { - this.scopes = scopes; - return this; - } - - public ResourcesQuery setVerbose(boolean verbose) { - this.verbose = verbose; - return this; - } - - public ResourcesQuery setQualifiers(String qualifiers) { - this.qualifiers = qualifiers; - return this; - } - - public ResourcesQuery setMetrics(List<WSMetrics.Metric> metrics) { - this.metrics = getMetricsWSRequest(metrics); - return this; - } - - public ResourcesQuery setMetric(WSMetrics.Metric m) { - this.metrics = m.getKey(); - return this; - } - - public ResourcesQuery setMetric(String metricKey) { - this.metrics = metricKey; - return this; - } - - private String getMetricsWSRequest(List<WSMetrics.Metric> metrics) { - StringBuilder metricsDelimByComma = new StringBuilder(64); - for (WSMetrics.Metric metric : metrics) { - metricsDelimByComma.append(metric.getKey()).append(","); - } - return metricsDelimByComma.substring(0, metricsDelimByComma.length() - 1); - } - - @Override - public String toString() { - String url = Utils.getServerApiUrl() + "/resources?"; - if (getResourceKey() != null) { - url += "resource=" + getResourceKey() + "&"; - } - if (metrics != null) { - url += "metrics=" + metrics + "&"; - } - if (scopes != null) { - url += "scopes=" + scopes + "&"; - } - if (qualifiers != null) { - url += "qualifiers=" + qualifiers + "&"; - } - if (depth != null) { - url += "depth=" + depth + "&"; - } - if (limit != null) { - url += "limit=" + limit + "&"; - } - if (rules != null) { - url += "rules=" + rules + "&"; - } - if (rulePriorities != null) { - url += "rule_priorities=" + rulePriorities + "&"; - } - if (verbose) { - url += "verbose=true&"; - } - return url; - } - - @Override - public void execute(QueryCallBack<Resources> callback) { - JsonUtils.requestJson(this.toString(), new JSONHandlerDispatcher<Resources>(callback) { - @Override - public Resources parseResponse(JavaScriptObject obj) { - return new Resources(parseResources(obj)); - } - }); - } - - public static List<Resource> parseResources(JavaScriptObject json) { - JSONArray array = new JSONArray(json); - List<Resource> resources = new ArrayList<Resource>(); - for (int i = 0; i < array.size(); i++) { - JSONObject jsStock = array.get(i).isObject(); - if (jsStock != null) { - resources.add(parseResource(jsStock)); - } - } - return resources; - } - - private static Resource parseResource(JSONObject json) { - Double id = JsonUtils.getDouble(json, "id"); - String key = JsonUtils.getString(json, "key"); - String name = JsonUtils.getString(json, "name"); - String longName = JsonUtils.getString(json, "lname"); - String qualifier = JsonUtils.getString(json, "qualifier"); - String language = JsonUtils.getString(json, "lang"); - String scope = JsonUtils.getString(json, "scope"); - Integer copy = JsonUtils.getInteger(json, "copy"); - Date date = JsonUtils.getDate(json, "date"); - - List<Measure> measures = null; - JSONValue measuresJson; - if ((measuresJson = json.get("msr")) != null) { - measures = parseMeasures(measuresJson, date); - } - - final Resource resource = new Resource(id.intValue(), key, name, scope, qualifier, language, copy, measures); - resource.setLongName(longName); - return resource; - } - - private static List<Measure> parseMeasures(JSONValue measures, Date date) { - List<Measure> projectMeasures = new ArrayList<Measure>(); - int len = JsonUtils.getArraySize(measures); - for (int i = 0; i < len; i++) { - JSONObject measure = JsonUtils.getArray(measures, i); - if (measure != null) { - Measure measureEntry = parseMeasure(measure, date); - if (measureEntry != null) { - projectMeasures.add(measureEntry); - } - } - } - return projectMeasures; - } - - private static Measure parseMeasure(JSONObject measure, Date date) { - String metric = JsonUtils.getString(measure, "key"); - if (metric == null) { - return null; - } - - final Measure m = new Measure(metric, JsonUtils.getDouble(measure, "val"), JsonUtils.getString(measure, "frmt_val")); - m.setData(JsonUtils.getString(measure, "data")); - String metricName = JsonUtils.getString(measure, "name"); - if (metricName != null) { - m.setMetricName(metricName); - } - - m.setRuleKey(JsonUtils.getString(measure, "rule_key")); - m.setRuleName(JsonUtils.getString(measure, "rule_name")); - m.setRulePriority(JsonUtils.getString(measure, "rule_priority")); - m.setDate(date); - return m; - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResponsePOJO.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResponsePOJO.java deleted file mode 100644 index 6a54fffb941..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResponsePOJO.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -/** - * Marker class for WS query response objects - */ -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public abstract class ResponsePOJO { - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java deleted file mode 100644 index dd4f5bf7873..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -/** - * @deprecated since 2.5 - */ -@Deprecated -public class Rule extends ResponsePOJO { - private String key; - private String name; - - public Rule(String key, String name) { - this.key = key; - this.name = name; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public String getCategory() { - return null; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SequentialQueries.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SequentialQueries.java deleted file mode 100644 index 55301f41367..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SequentialQueries.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.user.client.Timer; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public class SequentialQueries extends Query<VoidResponse> { - - private List<AjaxQuery<?>> queries = new ArrayList<AjaxQuery<?>>(); - private int sleepTimeBetweenCbChecks; - - private SequentialQueries(int sleepTimeBetweenCbChecks) { - this.sleepTimeBetweenCbChecks = sleepTimeBetweenCbChecks; - } - - public static SequentialQueries get() { - return new SequentialQueries(50); - } - - public static SequentialQueries get(int sleepTimeBetweenCbChecks) { - return new SequentialQueries(sleepTimeBetweenCbChecks); - } - - public <R extends ResponsePOJO> SequentialQueries add(Query<R> query, QueryCallBack<R> callback) { - queries.add(new AjaxQuery<R>(query, callback)); - return this; - } - - @Override - public void execute(final QueryCallBack<VoidResponse> callback) { - for (AjaxQuery<?> query : queries) { - query.execute(); - } - Timer queriesMonitor = new Timer() { - @Override - public void run() { - boolean queriesExecuted = true; - for (AjaxQuery<?> query : queries) { - if (!query.isCompleted()) { - queriesExecuted = false; - break; - } - } - if (queriesExecuted) { - callback.onResponse(new VoidResponse(), null); - cancel(); - } - } - }; - queriesMonitor.scheduleRepeating(sleepTimeBetweenCbChecks); - } - - private class AjaxQuery<R extends ResponsePOJO> { - private Query<R> query; - private QueryCallBack<R> callback; - - private boolean completed = false; - - public AjaxQuery(Query<R> query, QueryCallBack<R> callback) { - super(); - this.query = query; - this.callback = callback; - } - - private void execute() { - QueryCallBack<R> proxy = new QueryCallBack<R>() { - public void onError(int errorCode, String errorMessage) { - callback.onError(errorCode, errorMessage); - completed = true; - } - - public void onResponse(R response, JavaScriptObject jsonRawResponse) { - callback.onResponse(response, jsonRawResponse); - completed = true; - } - - public void onTimeout() { - callback.onTimeout(); - completed = true; - } - }; - query.execute(proxy); - } - - public boolean isCompleted() { - return completed; - } - - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/VoidResponse.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/VoidResponse.java deleted file mode 100644 index 6eee34741a2..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/VoidResponse.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public class VoidResponse extends ResponsePOJO { - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java deleted file mode 100644 index 5b8ffadd08a..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.webservices; - -import com.google.gwt.core.client.JavaScriptObject; - -import java.util.ArrayList; -import java.util.List; - -/** - * @deprecated since 2.8. Use sonar-gwt-api instead. - */ -@Deprecated -public final class WSMetrics { - - private WSMetrics() { - } - - private final static List<Metric> DICTIONNARY = new ArrayList<Metric>(); - - public static final Metric NCLOC = add(new Metric("ncloc")); - public static final Metric LINES = add(new Metric("lines")); - public static final Metric CLASSES = add(new Metric("classes")); - public static final Metric PACKAGES = add(new Metric("packages")); - public static final Metric FUNCTIONS = add(new Metric("functions")); - public static final Metric ACCESSORS = add(new Metric("accessors")); - public static final Metric FILES = add(new Metric("files")); - public static final Metric DIRECTORIES = add(new Metric("directories")); - public static final Metric PUBLIC_API = add(new Metric("public_api")); - - /* complexity */ - public static final Metric COMPLEXITY = add(new Metric("complexity")); - public static final Metric CLASS_COMPLEXITY = add(new Metric("class_complexity")); - public static final Metric FUNCTION_COMPLEXITY = add(new Metric("function_complexity")); - public static final Metric FILE_COMPLEXITY = add(new Metric("file_complexity")); - public static final Metric STATEMENTS = add(new Metric("statements")); - - public static final Metric CLASS_COMPLEXITY_DISTRIBUTION = add(new Metric("class_complexity_distribution")); - public static final Metric FUNCTION_COMPLEXITY_DISTRIBUTION = add(new Metric("function_complexity_distribution")); - - /* comments */ - public static final Metric COMMENT_LINES = add(new Metric("comment_lines")); - public static final Metric COMMENT_LINES_DENSITY = add(new Metric("comment_lines_density")); - public static final Metric PUBLIC_DOCUMENTED_API_DENSITY = add(new Metric("public_documented_api_density")); - public static final Metric PUBLIC_UNDOCUMENTED_API = add(new Metric("public_undocumented_api")); - public static final Metric COMMENTED_OUT_CODE_LINES = add(new Metric("commented_out_code_lines")); - - /* unit tests */ - public static final Metric TESTS = add(new Metric("tests")); - public static final Metric TESTS_EXECUTION_TIME = add(new Metric("test_execution_time")); - public static final Metric TEST_ERRORS = add(new Metric("test_errors")); - public static final Metric SKIPPED_TESTS = add(new Metric("skipped_tests")); - public static final Metric TEST_FAILURES = add(new Metric("test_failures")); - public static final Metric TEST_SUCCESS_DENSITY = add(new Metric("test_success_density")); - public static final Metric TEST_DATA = add(new Metric("test_data")); - - /* coverage */ - public static final Metric COVERAGE = add(new Metric("coverage")); - public static final Metric LINE_COVERAGE = add(new Metric("line_coverage")); - public static final Metric UNCOVERED_LINES = add(new Metric("uncovered_lines")); - public static final Metric BRANCH_COVERAGE = add(new Metric("branch_coverage")); - public static final Metric UNCOVERED_CONDITIONS = add(new Metric("uncovered_conditions")); - public static final Metric COVERAGE_LINE_HITS_DATA = add(new Metric("coverage_line_hits_data")); - public static final Metric BRANCH_COVERAGE_HITS_DATA = add(new Metric("branch_coverage_hits_data")); - - /* duplicated lines */ - public static final Metric DUPLICATED_LINES = add(new Metric("duplicated_lines")); - public static final Metric DUPLICATED_BLOCKS = add(new Metric("duplicated_blocks")); - public static final Metric DUPLICATED_FILES = add(new Metric("duplicated_files")); - public static final Metric DUPLICATED_LINES_DENSITY = add(new Metric("duplicated_lines_density")); - public static final Metric DUPLICATIONS_DATA = add(new Metric("duplications_data")); - - /* coding rules */ - public static final Metric VIOLATIONS_DENSITY = add(new Metric("violations_density")); - public static final Metric VIOLATIONS = add(new Metric("violations")); - public static final Metric WEIGHTED_VIOLATIONS = add(new Metric("weighted_violations")); - - /* design */ - public static final Metric LCOM4 = add(new Metric("lcom4")); - public static final Metric RFC = add(new Metric("rfc")); - - public static class MetricsList extends ResponsePOJO { - - private List<Metric> metrics = new ArrayList<Metric>(); - - public List<Metric> getMetrics() { - return metrics; - } - } - - /** - * Generates a callback that will update the metrics definitions from the WSMetrics metrics constants list with data - * received from a MetricsQuery call - * - * @param callback - * @return - */ - public static QueryCallBack<MetricsList> getUpdateMetricsFromServer(final QueryCallBack<MetricsList> callback) { - return new QueryCallBack<MetricsList>() { - public void onResponse(MetricsList response, JavaScriptObject jsonRawResponse) { - for (Metric metric : response.getMetrics()) { - Metric WSMetricConstant = get(metric.getKey()); - if (WSMetricConstant != null) { - WSMetricConstant.updateFrom(metric); - } else { - add(metric); - } - } - callback.onResponse(response, jsonRawResponse); - } - - public void onError(int errorCode, String errorMessage) { - callback.onError(errorCode, errorMessage); - } - - public void onTimeout() { - callback.onTimeout(); - } - }; - } - - public static class Metric { - public enum ValueType { - INT, FLOAT, PERCENT, BOOL, STRING, MILLISEC, DATA, LEVEL, DISTRIB, RATING - } - - private String key; - private String name; - private String description; - private String domain; - private boolean qualitative; - private boolean userManaged; - private int direction; - private ValueType type; - - public Metric(String key) { - super(); - this.key = key; - } - - public Metric(String key, String name, String description, String domain, - boolean qualitative, boolean userManaged, int direction, ValueType type) { - super(); - this.key = key; - this.name = name; - this.description = description; - this.domain = domain; - this.qualitative = qualitative; - this.userManaged = userManaged; - this.direction = direction; - this.type = type; - } - - public void updateFrom(Metric metric) { - this.name = metric.getName(); - this.description = metric.getDescription(); - this.domain = metric.getDomain(); - this.qualitative = metric.isQualitative(); - this.userManaged = metric.isUserManaged(); - this.direction = metric.getDirection(); - this.type = metric.getType(); - } - - public String getName() { - return name; - } - - public ValueType getType() { - return type; - } - - public String getDescription() { - return description; - } - - public String getDomain() { - return domain; - } - - public boolean isQualitative() { - return qualitative; - } - - public boolean isUserManaged() { - return userManaged; - } - - public int getDirection() { - return direction; - } - - public String getKey() { - return key; - } - - @Override - public int hashCode() { - return key.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Metric)) { - return false; - } - if (this == obj) { - return true; - } - Metric other = (Metric) obj; - return key.equals(other.getKey()); - } - } - - public static Metric add(Metric metric) { - if (!DICTIONNARY.contains(metric)) { - DICTIONNARY.add(metric); - } - return metric; - } - - public static Metric get(String metricKey) { - for (Metric metric : DICTIONNARY) { - if (metric.getKey().equals(metricKey)) { - return metric; - } - } - return new Metric(metricKey); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/widgets/LoadingLabel.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/widgets/LoadingLabel.java deleted file mode 100644 index 440485a24d8..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/widgets/LoadingLabel.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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 3 of the License, or (at your option) any later version. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.web.gwt.client.widgets; - -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HTML; - -public class LoadingLabel extends Composite { - public LoadingLabel() { - this("loading..."); - getElement().setId("loading"); - } - - public LoadingLabel(String text) { - initWidget(new HTML("<div class='loading'>" + text + "</div>")); - } -} |