import com.google.common.io.Resources;
import org.sonar.api.server.ws.RailsHandler;
import org.sonar.api.server.ws.WebService;
+import org.sonar.server.ws.RemovedWebServiceHandler;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
NewController controller = context.createController(API_ENDPOINT)
.setDescription("Manage quality profiles. Deprecated since 5.2.")
.setSince("4.4");
-
-
restoreAction.define(controller);
defineListAction(controller);
defineIndexAction(controller);
-
controller.done();
}
private static void defineIndexAction(NewController controller) {
- WebService.NewAction action = controller.createAction("index")
- .setDescription("Get a profile.")
+ controller.createAction("index")
+ .setDescription("Get a profile.<br/>" +
+ "The web service is removed and you're invited to use api/qualityprofiles/search instead")
.setSince("3.3")
.setDeprecatedSince("5.2")
- .setHandler(RailsHandler.INSTANCE)
+ .setHandler(RemovedWebServiceHandler.INSTANCE)
.setResponseExample(Resources.getResource(ProfilesWs.class, "example-index.json"));
-
- action.createParam("language")
- .setDescription("Profile language")
- .setRequired(true)
- .setExampleValue("java");
- action.createParam("name")
- .setDescription("Profile name. If no profile name is given, default profile for the given language will be returned")
- .setRequired(true)
- .setExampleValue("Sonar way");
- RailsHandler.addFormatParam(action);
}
private static void defineListAction(NewController controller) {
import org.sonar.api.server.ws.WebService;
import org.sonar.server.qualityprofile.QProfileBackuper;
import org.sonar.server.user.UserSession;
+import org.sonar.server.ws.RemovedWebServiceHandler;
import org.sonar.server.ws.WsTester;
import static org.assertj.core.api.Assertions.assertThat;
WebService.Action restoreProfiles = controller.action("index");
assertThat(restoreProfiles).isNotNull();
- assertThat(restoreProfiles.handler()).isInstanceOf(RailsHandler.class);
+ assertThat(restoreProfiles.handler()).isInstanceOf(RemovedWebServiceHandler.class);
assertThat(restoreProfiles.responseExampleAsString()).isNotEmpty();
- assertThat(restoreProfiles.params()).hasSize(3);
+ assertThat(restoreProfiles.params()).isEmpty();
}
@Test
format.text { render :text => text_not_supported }
end
end
-
- # GET /api/profiles?language=<language>[&name=<name>]
- def index
- require_parameters :language
-
- language=params[:language]
- name=params[:name]
- if name.blank?
- @profile=Profile.by_default(language)
- else
- @profile=Profile.find_by_name_and_language(name, language)
- end
- not_found('Profile not found') unless @profile
- @active_rules=filter_rules()
-
- respond_to do |format|
- format.json { render :json => jsonp(to_json) }
- format.xml { render :xml => to_xml }
- format.text { render :text => text_not_supported }
- end
- end
private