diff options
author | Julien HENRY <henryju@yahoo.fr> | 2011-01-19 02:44:34 +0800 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-01-20 05:24:23 +0800 |
commit | 1fbdcfbd155563691ded8f80d4fe2d03f754c897 (patch) | |
tree | fda45b0a815197a5882aaded09670b6726be6368 /sonar-ws-client/src/main/java/org | |
parent | 94c86319caf6c3a1fd3d6c617f8f702b5c0c4fcb (diff) | |
download | sonarqube-1fbdcfbd155563691ded8f80d4fe2d03f754c897.tar.gz sonarqube-1fbdcfbd155563691ded8f80d4fe2d03f754c897.zip |
SONAR-1664: Add access to project settings/properties
Diffstat (limited to 'sonar-ws-client/src/main/java/org')
4 files changed, 290 insertions, 3 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java new file mode 100644 index 00000000000..d1d2921d10c --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java @@ -0,0 +1,101 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * 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.wsclient.services; + +/** + * @since 2.6 + */ +public class PropertyCreateQuery extends CreateQuery<Property> { + + private String key; + private String value; + private String resourceKeyOrId; + + public PropertyCreateQuery() { + } + + public PropertyCreateQuery(String key, String value) { + this.key = key; + this.value = value; + } + + public PropertyCreateQuery(String key, String value, String resourceKeyOrId) { + this.key = key; + this.value = value; + this.resourceKeyOrId = resourceKeyOrId; + } + + public PropertyCreateQuery(Property property) { + this.key = property.getKey(); + this.value = property.getValue(); + } + + public String getKey() { + return key; + } + + public PropertyCreateQuery setKey(String key) { + this.key = key; + return this; + } + + public String getValue() { + return value; + } + + public PropertyCreateQuery setValue(String value) { + this.value = value; + return this; + } + + public String getResourceKeyOrId() { + return resourceKeyOrId; + } + + public PropertyCreateQuery setResourceKeyOrId(String resourceKeyOrId) { + this.resourceKeyOrId = resourceKeyOrId; + return this; + } + + @Override + public String getUrl() { + StringBuilder url = new StringBuilder(); + url.append(PropertyQuery.BASE_URL); + url.append("/").append(key); + url.append('?'); + appendUrlParameter(url, "value", value); + appendUrlParameter(url, "resource", resourceKeyOrId); + return url.toString(); + } + + /** + * Property value is transmitted through request body as content may + * exceed URL size allowed by the server. + */ + @Override + public String getBody() { + return value; + } + + @Override + public Class<Property> getModelClass() { + return Property.class; + } +} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java new file mode 100644 index 00000000000..07c6a193f10 --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java @@ -0,0 +1,70 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * 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.wsclient.services; + +/** + * @since 2.6 + */ +public class PropertyDeleteQuery extends DeleteQuery<Property> { + + private String key; + private String resourceKeyOrId; + + public PropertyDeleteQuery(String key) { + this.key = key; + } + + public PropertyDeleteQuery(String key, String resourceKeyOrId) { + this.key = key; + this.resourceKeyOrId = resourceKeyOrId; + } + + public PropertyDeleteQuery(Property property) { + this.key = property.getKey(); + } + + public String getKey() { + return key; + } + + public PropertyDeleteQuery setKey(String key) { + this.key = key; + return this; + } + + public String getResourceKeyOrId() { + return resourceKeyOrId; + } + + public PropertyDeleteQuery setResourceKeyOrId(String resourceKeyOrId) { + this.resourceKeyOrId = resourceKeyOrId; + return this; + } + + @Override + public String getUrl() { + StringBuilder url = new StringBuilder(); + url.append(PropertyQuery.BASE_URL); + url.append("/").append(key); + url.append('?'); + appendUrlParameter(url, "resource", resourceKeyOrId); + return url.toString(); + } +} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java index 1e005cac291..8fa3a95ea9d 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java @@ -23,6 +23,7 @@ public class PropertyQuery extends Query<Property> { public static final String BASE_URL = "/api/properties"; private String key = null; + private String resourceKeyOrId = null; public String getKey() { return key; @@ -33,13 +34,24 @@ public class PropertyQuery extends Query<Property> { return this; } + public String getResourceKeyOrId() { + return resourceKeyOrId; + } + + public PropertyQuery setResourceKeyOrId(String resourceKeyOrId) { + this.resourceKeyOrId = resourceKeyOrId; + return this; + } + @Override public String getUrl() { - String url = BASE_URL; + StringBuilder url = new StringBuilder(BASE_URL); if (key != null) { - url += "/" + key; + url.append("/").append(key); } - return url + "?"; + url.append('?'); + appendUrlParameter(url, "resource", resourceKeyOrId); + return url.toString(); } @Override @@ -54,4 +66,8 @@ public class PropertyQuery extends Query<Property> { public static PropertyQuery createForKey(String key) { return new PropertyQuery().setKey(key); } + + public static PropertyQuery createForResource(String key, String resourceKeyOrId) { + return new PropertyQuery().setKey(key).setResourceKeyOrId(resourceKeyOrId); + } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java new file mode 100644 index 00000000000..f66583fbe9f --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java @@ -0,0 +1,100 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * 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.wsclient.services; + +/** + * @since 2.6 + */ +public class PropertyUpdateQuery extends UpdateQuery<Property> { + + private String key; + private String value; + private String resourceKeyOrId; + + public PropertyUpdateQuery() { + } + + public PropertyUpdateQuery(String key, String value) { + this.key = key; + this.value = value; + } + + public PropertyUpdateQuery(String key, String value, String resourceKeyOrId) { + this.key = key; + this.value = value; + this.resourceKeyOrId = resourceKeyOrId; + } + + public PropertyUpdateQuery(Property property) { + this.key = property.getKey(); + this.value = property.getValue(); + } + + public String getKey() { + return key; + } + + public PropertyUpdateQuery setKey(String key) { + this.key = key; + return this; + } + + public String getValue() { + return value; + } + + public PropertyUpdateQuery setValue(String value) { + this.value = value; + return this; + } + + public String getResourceKeyOrId() { + return resourceKeyOrId; + } + + public PropertyUpdateQuery setResourceKeyOrId(String resourceKeyOrId) { + this.resourceKeyOrId = resourceKeyOrId; + return this; + } + + @Override + public String getUrl() { + StringBuilder url = new StringBuilder(); + url.append(PropertyQuery.BASE_URL); + url.append("/").append(key); + url.append('?'); + appendUrlParameter(url, "resource", resourceKeyOrId); + return url.toString(); + } + + /** + * Property value is transmitted through request body as content may + * exceed URL size allowed by the server. + */ + @Override + public String getBody() { + return value; + } + + @Override + public Class<Property> getModelClass() { + return Property.class; + } +} |