Skip to content

Commit

Permalink
resources: POST shouldn't update a schema
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
  • Loading branch information
Pierre-Alexandre Meyer committed Dec 9, 2011
1 parent 85d552f commit da8cdcc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Expand Up @@ -2,8 +2,6 @@

import com.ning.jetty.base.modules.ServerModuleBuilder;
import com.ning.jetty.core.listeners.SetupServer;
import com.ning.jetty.utils.healthchecks.DBIHealthCheck;
import com.ning.jetty.utils.log4j.Log4JMBean;
import com.ning.metrics.goodwill.binder.config.GoodwillConfig;
import com.ning.metrics.goodwill.binder.modules.GoodwillServicesModule;

Expand All @@ -16,7 +14,7 @@ public void contextInitialized(ServletContextEvent event)
{
final ServerModuleBuilder builder = new ServerModuleBuilder()
.addConfig(GoodwillConfig.class)
.addJMXExport(Log4JMBean.class)
.enableLog4J()
.setAreciboProfile(System.getProperty("action.arecibo.profile", "ning.jmx:name=MonitoringProfile"))
.addModule(new GoodwillServicesModule())
.addResource("com.ning.metrics.goodwill.endpoint");
Expand Down
Expand Up @@ -18,7 +18,6 @@

import com.google.inject.Binder;
import com.google.inject.Module;
import com.ning.jetty.utils.log4j.Log4JMBean;
import com.ning.metrics.goodwill.sink.GoodwillSink;
import com.ning.metrics.goodwill.store.GoodwillStore;

Expand All @@ -27,8 +26,6 @@ public class GoodwillServicesModule implements Module
@Override
public void configure(final Binder binder)
{
binder.bind(Log4JMBean.class).asEagerSingleton();

binder.bind(GoodwillSink.class).toProvider(GoodwillSinkProvider.class).asEagerSingleton();
binder.bind(GoodwillStore.class).toProvider(GoodwillStoreProvider.class).asEagerSingleton();
}
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/ning/metrics/goodwill/endpoint/Registrar.java
Expand Up @@ -137,12 +137,15 @@ public Response deleteType(@PathParam("type") String typeName) throws IOExceptio

@POST
@Consumes("application/json")
public Response post(
String jsonThriftTypeString
)
public Response post(String jsonThriftTypeString)
{
try {
GoodwillSchema schema = GoodwillSchema.decode(jsonThriftTypeString);
// Use PUT to update a Schema
if (store.findByName(schema.getName()) != null) {
return Response.status(Response.Status.CONFLICT).build();
}

store.addType(schema);
log.info(String.format("Created new ThriftType <%s> from JSON <%s>", schema.toString(), jsonThriftTypeString));
}
Expand All @@ -156,9 +159,7 @@ public Response post(

@PUT
@Consumes("application/json")
public Response put(
String jsonThriftTypeString
)
public Response put(String jsonThriftTypeString)
{
try {
GoodwillSchema thriftType = GoodwillSchema.decode(jsonThriftTypeString);
Expand Down

0 comments on commit da8cdcc

Please sign in to comment.