fix deployment

This commit is contained in:
Athou
2013-03-28 19:41:40 +01:00
parent b4d4015f4b
commit 5383332182
4 changed files with 25 additions and 5 deletions

View File

@@ -1,9 +1,26 @@
package com.commafeed.frontend.rest;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import com.commafeed.frontend.rest.resources.EntriesREST;
import com.commafeed.frontend.rest.resources.SettingsREST;
import com.commafeed.frontend.rest.resources.SubscriptionsREST;
import com.google.common.collect.Sets;
@ApplicationPath("/rest")
public class RESTApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> set = Sets.newHashSet();
set.add(JSONMessageBodyReaderWriter.class);
set.add(SubscriptionsREST.class);
set.add(EntriesREST.class);
set.add(SettingsREST.class);
return set;
}
}

View File

@@ -14,6 +14,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.apache.wicket.ThreadContext;
@@ -102,7 +103,9 @@ public abstract class AbstractREST {
public Object checkSecurity(InvocationContext context) throws Exception {
User user = getUser();
if (user == null) {
throw new WebApplicationException(Status.UNAUTHORIZED);
throw new WebApplicationException(Response
.status(Status.UNAUTHORIZED)
.entity("You need to be authenticated to do this.").build());
}
boolean allowed = false;
@@ -118,7 +121,8 @@ public abstract class AbstractREST {
SecurityCheck.class));
}
if (!allowed) {
throw new WebApplicationException(Status.FORBIDDEN);
throw new WebApplicationException(Response.status(Status.FORBIDDEN)
.entity("You are not authorized to do this.").build());
}
return context.proceed();