Merge pull request #946 from metamx/MoreMediaTypes

Changed all "application/json" to MediaType.APPLICATION_JSON  except for in druid.js
This commit is contained in:
Fangjin Yang 2014-12-08 15:24:21 -07:00
commit 623443a145
18 changed files with 81 additions and 63 deletions

View File

@ -36,6 +36,7 @@ import io.druid.indexing.common.task.Task;
import org.jboss.netty.channel.ChannelException;
import org.joda.time.Duration;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@ -94,7 +95,7 @@ public class RemoteTaskActionClient implements TaskActionClient
try {
response = httpClient.post(serviceUri.toURL())
.setContent("application/json", dataToSend)
.setContent(MediaType.APPLICATION_JSON, dataToSend)
.go(new StatusResponseHandler(Charsets.UTF_8))
.get();
}

View File

@ -58,6 +58,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
@ -100,8 +101,8 @@ public class OverlordResource
@POST
@Path("/task")
@Consumes("application/json")
@Produces("application/json")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response taskPost(final Task task)
{
return asLeaderWith(
@ -127,7 +128,7 @@ public class OverlordResource
@GET
@Path("/task/{taskid}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getTaskPayload(@PathParam("taskid") String taskid)
{
return optionalTaskResponse(taskid, "payload", taskStorageQueryAdapter.getTask(taskid));
@ -135,7 +136,7 @@ public class OverlordResource
@GET
@Path("/task/{taskid}/status")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getTaskStatus(@PathParam("taskid") String taskid)
{
return optionalTaskResponse(taskid, "status", taskStorageQueryAdapter.getStatus(taskid));
@ -143,7 +144,7 @@ public class OverlordResource
@GET
@Path("/task/{taskid}/segments")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getTaskSegments(@PathParam("taskid") String taskid)
{
final Set<DataSegment> segments = taskStorageQueryAdapter.getInsertedSegments(taskid);
@ -152,7 +153,7 @@ public class OverlordResource
@POST
@Path("/task/{taskid}/shutdown")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response doShutdown(@PathParam("taskid") final String taskid)
{
return asLeaderWith(
@ -171,7 +172,7 @@ public class OverlordResource
@GET
@Path("/worker")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getWorkerConfig()
{
if (workerConfigRef == null) {
@ -183,7 +184,7 @@ public class OverlordResource
@POST
@Path("/worker")
@Consumes("application/json")
@Consumes(MediaType.APPLICATION_JSON)
public Response setWorkerConfig(
final WorkerBehaviorConfig workerBehaviorConfig
)
@ -201,7 +202,7 @@ public class OverlordResource
@Deprecated
@GET
@Path("/worker/setup")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getWorkerSetupData()
{
if (workerSetupDataRef == null) {
@ -214,7 +215,7 @@ public class OverlordResource
@Deprecated
@POST
@Path("/worker/setup")
@Consumes("application/json")
@Consumes(MediaType.APPLICATION_JSON)
public Response setWorkerSetupData(
final WorkerSetupData workerSetupData
)
@ -230,7 +231,7 @@ public class OverlordResource
@POST
@Path("/action")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public <T> Response doAction(final TaskActionHolder<T> holder)
{
return asLeaderWith(
@ -264,7 +265,7 @@ public class OverlordResource
@GET
@Path("/waitingTasks")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getWaitingTasks()
{
return workItemsResponse(
@ -311,7 +312,7 @@ public class OverlordResource
@GET
@Path("/pendingTasks")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getPendingTasks()
{
return workItemsResponse(
@ -328,7 +329,7 @@ public class OverlordResource
@GET
@Path("/runningTasks")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getRunningTasks()
{
return workItemsResponse(
@ -345,7 +346,7 @@ public class OverlordResource
@GET
@Path("/completeTasks")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getCompleteTasks()
{
final List<TaskResponseObject> completeTasks = Lists.transform(
@ -370,7 +371,7 @@ public class OverlordResource
@GET
@Path("/workers")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getWorkers()
{
return asLeaderWith(
@ -388,7 +389,7 @@ public class OverlordResource
@GET
@Path("/scaling")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getScalingState()
{
// Don't use asLeaderWith, since we want to return 200 instead of 503 when missing an autoscaler.

View File

@ -39,6 +39,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.InputStream;
@ -72,7 +73,7 @@ public class WorkerResource
@POST
@Path("/disable")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response doDisable()
{
try {
@ -86,7 +87,7 @@ public class WorkerResource
@POST
@Path("/enable")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response doEnable()
{
try {
@ -100,7 +101,7 @@ public class WorkerResource
@GET
@Path("/enabled")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response isEnabled()
{
try {
@ -115,7 +116,7 @@ public class WorkerResource
@GET
@Path("/tasks")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getTasks()
{
try {
@ -142,7 +143,7 @@ public class WorkerResource
@POST
@Path("/task/{taskid}/shutdown")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response doShutdown(@PathParam("taskid") String taskid)
{
try {

View File

@ -32,6 +32,7 @@ import io.druid.guice.annotations.Global;
import io.druid.timeline.DataSegment;
import org.joda.time.Interval;
import javax.ws.rs.core.MediaType;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
@ -94,7 +95,7 @@ public class IndexingServiceClient
{
try {
return client.post(new URL(String.format("%s/task", baseUrl())))
.setContent("application/json", jsonMapper.writeValueAsBytes(queryObject))
.setContent(MediaType.APPLICATION_JSON, jsonMapper.writeValueAsBytes(queryObject))
.go(RESPONSE_HANDLER)
.get();
}

View File

@ -38,6 +38,7 @@ import io.druid.data.input.impl.MapInputRowParser;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.Collection;
@ -125,7 +126,7 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory<MapInputRow
@POST
@Path("/push-events")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response addAll(Collection<Map<String, Object>> events)
{
log.debug("Adding %,d events to firehose: %s", events.size(), serviceName);

View File

@ -36,6 +36,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -73,7 +74,7 @@ public class ClientInfoResource
}
@GET
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Iterable<String> getDataSources()
{
return getSegmentsForDatasources().keySet();
@ -81,7 +82,7 @@ public class ClientInfoResource
@GET
@Path("/{dataSourceName}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> getDatasource(
@PathParam("dataSourceName") String dataSourceName,
@QueryParam("interval") String interval
@ -95,7 +96,7 @@ public class ClientInfoResource
@GET
@Path("/{dataSourceName}/dimensions")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Iterable<String> getDatasourceDimensions(
@PathParam("dataSourceName") String dataSourceName,
@QueryParam("interval") String interval
@ -127,7 +128,7 @@ public class ClientInfoResource
@GET
@Path("/{dataSourceName}/metrics")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Iterable<String> getDatasourceMetrics(
@PathParam("dataSourceName") String dataSourceName,
@QueryParam("interval") String interval

View File

@ -27,6 +27,7 @@ import io.druid.initialization.Initialization;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@ -37,7 +38,7 @@ import java.util.List;
public class StatusResource
{
@GET
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Status doGet()
{
return new Status(Initialization.getLoadedModules(DruidModule.class));

View File

@ -38,6 +38,7 @@ import io.druid.query.QuerySegmentWalker;
import io.druid.query.SegmentDescriptor;
import org.joda.time.Interval;
import javax.ws.rs.core.MediaType;
import java.net.URL;
import java.util.List;
import java.util.Map;
@ -102,7 +103,7 @@ public class BridgeQuerySegmentWalker implements QuerySegmentWalker
StatusResponseHolder response = httpClient.post(new URL(url))
.setContent(
"application/json",
MediaType.APPLICATION_JSON,
jsonMapper.writeValueAsBytes(query)
)
.go(responseHandler)

View File

@ -28,6 +28,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
@ -46,7 +47,7 @@ public class CoordinatorDynamicConfigsResource
}
@GET
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getDynamicConfigs()
{
return Response.ok(
@ -58,7 +59,7 @@ public class CoordinatorDynamicConfigsResource
}
@POST
@Consumes("application/json")
@Consumes(MediaType.APPLICATION_JSON)
public Response setDynamicConfigs(final CoordinatorDynamicConfig dynamicConfig)
{
if (!manager.set(CoordinatorDynamicConfig.CONFIG_KEY, dynamicConfig)) {

View File

@ -32,6 +32,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
@ -51,7 +52,7 @@ public class CoordinatorResource
@GET
@Path("/leader")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getLeader()
{
return Response.ok(coordinator.getCurrentLeader()).build();
@ -59,7 +60,7 @@ public class CoordinatorResource
@GET
@Path("/loadstatus")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getLoadStatus(
@QueryParam("simple") String simple,
@QueryParam("full") String full
@ -77,7 +78,7 @@ public class CoordinatorResource
@GET
@Path("/loadqueue")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getLoadQueue(
@QueryParam("simple") String simple,
@QueryParam("full") String full

View File

@ -47,6 +47,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Comparator;
import java.util.List;
@ -76,7 +77,7 @@ public class DatasourcesResource
}
@GET
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getQueryableDataSources(
@QueryParam("full") String full,
@QueryParam("simple") String simple
@ -122,7 +123,7 @@ public class DatasourcesResource
@GET
@Path("/{dataSourceName}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getTheDataSource(
@PathParam("dataSourceName") final String dataSourceName,
@QueryParam("full") final String full
@ -142,7 +143,7 @@ public class DatasourcesResource
@POST
@Path("/{dataSourceName}")
@Consumes("application/json")
@Consumes(MediaType.APPLICATION_JSON)
public Response enableDataSource(
@PathParam("dataSourceName") final String dataSourceName
)
@ -156,7 +157,7 @@ public class DatasourcesResource
@DELETE
@Path("/{dataSourceName}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteDataSource(
@PathParam("dataSourceName") final String dataSourceName,
@QueryParam("kill") final String kill,
@ -190,7 +191,7 @@ public class DatasourcesResource
@GET
@Path("/{dataSourceName}/intervals")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceIntervals(
@PathParam("dataSourceName") String dataSourceName,
@QueryParam("simple") String simple,
@ -250,7 +251,7 @@ public class DatasourcesResource
@GET
@Path("/{dataSourceName}/intervals/{interval}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceSpecificInterval(
@PathParam("dataSourceName") String dataSourceName,
@PathParam("interval") String interval,
@ -317,7 +318,7 @@ public class DatasourcesResource
@GET
@Path("/{dataSourceName}/segments")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceSegments(
@PathParam("dataSourceName") String dataSourceName,
@QueryParam("full") String full
@ -350,7 +351,7 @@ public class DatasourcesResource
@GET
@Path("/{dataSourceName}/segments/{segmentId}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceSegment(
@PathParam("dataSourceName") String dataSourceName,
@PathParam("segmentId") String segmentId
@ -388,7 +389,7 @@ public class DatasourcesResource
@POST
@Path("/{dataSourceName}/segments/{segmentId}")
@Consumes("application/json")
@Consumes(MediaType.APPLICATION_JSON)
public Response enableDatasourceSegment(
@PathParam("dataSourceName") String dataSourceName,
@PathParam("segmentId") String segmentId
@ -403,7 +404,7 @@ public class DatasourcesResource
@GET
@Path("/{dataSourceName}/tiers")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceTiers(
@PathParam("dataSourceName") String dataSourceName
)

View File

@ -7,6 +7,7 @@ import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/druid/historical/v1")
@ -24,7 +25,7 @@ public class HistoricalResource
@GET
@Path("/loadstatus")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getLoadStatus()
{
return Response.ok(ImmutableMap.of("cacheInitialized", coordinator.isStarted())).build();

View File

@ -32,6 +32,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Collections;
import java.util.List;
@ -53,7 +54,7 @@ public class MetadataResource
@GET
@Path("/datasources")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getDatabaseDataSources(
@QueryParam("full") String full,
@QueryParam("includeDisabled") String includeDisabled
@ -88,7 +89,7 @@ public class MetadataResource
@GET
@Path("/datasources/{dataSourceName}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getDatabaseSegmentDataSource(
@PathParam("dataSourceName") final String dataSourceName
)
@ -103,7 +104,7 @@ public class MetadataResource
@GET
@Path("/datasources/{dataSourceName}/segments")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getDatabaseSegmentDataSourceSegments(
@PathParam("dataSourceName") String dataSourceName,
@QueryParam("full") String full
@ -136,7 +137,7 @@ public class MetadataResource
@GET
@Path("/datasources/{dataSourceName}/segments/{segmentId}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getDatabaseSegmentDataSourceSegment(
@PathParam("dataSourceName") String dataSourceName,
@PathParam("segmentId") String segmentId

View File

@ -30,6 +30,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
@ -49,7 +50,7 @@ public class RulesResource
}
@GET
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getRules()
{
return Response.ok(databaseRuleManager.getAllRules()).build();
@ -57,7 +58,7 @@ public class RulesResource
@GET
@Path("/{dataSourceName}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getDatasourceRules(
@PathParam("dataSourceName") final String dataSourceName,
@QueryParam("full") final String full
@ -74,7 +75,7 @@ public class RulesResource
@POST
@Path("/{dataSourceName}")
@Consumes("application/json")
@Consumes(MediaType.APPLICATION_JSON)
public Response setDatasourceRules(
@PathParam("dataSourceName") final String dataSourceName,
final List<Rule> rules

View File

@ -35,6 +35,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Map;
@ -66,7 +67,7 @@ public class ServersResource
}
@GET
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getClusterServers(
@QueryParam("full") String full,
@QueryParam("simple") String simple
@ -113,7 +114,7 @@ public class ServersResource
@GET
@Path("/{serverName}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getServer(
@PathParam("serverName") String serverName,
@QueryParam("simple") String simple
@ -136,7 +137,7 @@ public class ServersResource
@GET
@Path("/{serverName}/segments")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getServerSegments(
@PathParam("serverName") String serverName,
@QueryParam("full") String full
@ -169,7 +170,7 @@ public class ServersResource
@GET
@Path("/{serverName}/segments/{segmentId}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getServerSegment(
@PathParam("serverName") String serverName,
@PathParam("segmentId") String segmentId

View File

@ -39,6 +39,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Map;
import java.util.Set;
@ -59,7 +60,7 @@ public class TiersResource
}
@GET
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getTiers(
@QueryParam("simple") String simple
)
@ -95,7 +96,7 @@ public class TiersResource
@GET
@Path("/{tierName}")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response getTierDatasources(
@PathParam("tierName") String tierName,
@QueryParam("simple") String simple

View File

@ -50,6 +50,7 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import javax.annotation.Nullable;
import javax.ws.rs.core.MediaType;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
@ -143,7 +144,7 @@ public class SQLRunner
URL url = new URL(String.format("http://%s/druid/v2/?pretty", hostname));
final URLConnection urlConnection = url.openConnection();
urlConnection.addRequestProperty("content-type", "application/json");
urlConnection.addRequestProperty("content-type", MediaType.APPLICATION_JSON);
urlConnection.getOutputStream().write(queryStr.getBytes(Charsets.UTF_8));
BufferedReader stdInput = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), Charsets.UTF_8));

View File

@ -63,6 +63,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
@ -275,7 +276,7 @@ public class JettyTest
@GET
@Path("/hello")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response hello()
{
try {
@ -293,7 +294,7 @@ public class JettyTest
{
@GET
@Path("/exception")
@Produces("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response exception(
@Context HttpServletResponse resp
) throws IOException