/** {@inheritDoc} */ public Future<Void> deleteMessageCollection(UserId userId, String msgCollId, SecurityToken token) throws ProtocolException { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "this functionality is not yet available"); }
protected ResponseItem responseItemFromException(Throwable t) { if (t instanceof ProtocolException) { ProtocolException pe = (ProtocolException) t; LOG.log(Level.INFO, "Returning a response error as result of a protocol exception", pe); return new ResponseItem(pe.getCode(), pe.getMessage(), pe.getResponse()); } LOG.log(Level.WARNING, "Returning a response error as result of an exception", t); return new ResponseItem(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); }
public ProtocolException(int errorCode, String errorMessage, Throwable cause) { super(errorMessage, cause); checkErrorCode(errorCode); this.errorCode = errorCode; this.response = null; }
@Test public void testRestHandler_serviceDoesntExist() { RestHandler restHandler = registry.getRestHandler("/makebelieve", "GET"); try { Future<?> future = restHandler.execute(Maps.<String, String[]>newHashMap(), null, null, null); future.get(); fail("Expect exception for missing method"); } catch (ExecutionException t) { assertSame(t.getCause().getClass(), ProtocolException.class); Assert.assertEquals(HttpServletResponse.SC_NOT_IMPLEMENTED, ((ProtocolException) t.getCause()).getCode()); } catch (Throwable t) { fail("Unexpected exception " + t.toString()); } }
@Test public void testRestHandler_serviceDoesntExist() { RestHandler restHandler = registry.getRestHandler("/makebelieve", "GET"); try { Future<?> future = restHandler.execute(Maps.<String, String[]>newHashMap(), null, null, null); future.get(); fail("Expect exception for missing method"); } catch (ExecutionException t) { assertSame(t.getCause().getClass(), ProtocolException.class); Assert.assertEquals(HttpServletResponse.SC_NOT_IMPLEMENTED, ((ProtocolException) t.getCause()).getCode()); } catch (Throwable t) { fail("Unexpected exception " + t.toString()); } }
public Future<Void> modifyMessage(UserId userId, String msgCollId, String messageId, Message message, SecurityToken token) throws ProtocolException { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "Not Implemented"); } }
@Test public void testRestHandler_serviceDoesntExist() { RestHandler restHandler = registry.getRestHandler("/makebelieve", "GET"); try { Future<?> future = restHandler.execute(Maps.<String, String[]>newHashMap(), null, null, null); future.get(); fail("Expect exception for missing method"); } catch (ExecutionException t) { assertSame(t.getCause().getClass(), ProtocolException.class); Assert.assertEquals(HttpServletResponse.SC_NOT_IMPLEMENTED, ((ProtocolException) t.getCause()).getCode()); } catch (Throwable t) { fail("Unexpected exception " + t.toString()); } }
protected ResponseItem responseItemFromException(Throwable t) { if (t instanceof ProtocolException) { ProtocolException pe = (ProtocolException) t; LOG.log(Level.INFO, "Returning a response error as result of a protocol exception", pe); return new ResponseItem(pe.getCode(), pe.getMessage(), pe.getResponse()); } LOG.log(Level.WARNING, "Returning a response error as result of an exception", t); return new ResponseItem(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); }
public ProtocolException(int errorCode, String errorMessage, Object response) { super(errorMessage); checkErrorCode(errorCode); this.errorCode = errorCode; this.response = response; }
/** {@inheritDoc} */ public Future<Void> deleteMessages(UserId userId, String msgCollId, List<String> ids, SecurityToken token) throws ProtocolException { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "this functionality is not yet available"); }
@Test public void testRestHandler_serviceDoesntExist() { RestHandler restHandler = registry.getRestHandler("/makebelieve", "GET"); try { Future<?> future = restHandler.execute(Maps.<String, String[]>newHashMap(), null, null, null); future.get(); fail("Expect exception for missing method"); } catch (ExecutionException t) { assertSame(t.getCause().getClass(), ProtocolException.class); Assert.assertEquals(HttpServletResponse.SC_NOT_IMPLEMENTED, ((ProtocolException) t.getCause()).getCode()); } catch (Throwable t) { fail("Unexpected exception " + t.toString()); } }
protected ResponseItem responseItemFromException(Throwable t) { if (t instanceof ProtocolException) { ProtocolException pe = (ProtocolException) t; if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "responseItemFromException", MessageKeys.API_SERVLET_PROTOCOL_EXCEPTION,pe); } return new ResponseItem(pe.getCode(), pe.getMessage(), pe.getResponse()); } if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "responseItemFromException", MessageKeys.API_SERVLET_EXCEPTION,t); } return new ResponseItem(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); }
public ProtocolException(int errorCode, String errorMessage, Object response) { super(errorMessage); checkErrorCode(errorCode); this.errorCode = errorCode; this.response = response; }
/** {@inheritDoc} */ public Future<MessageCollection> createMessageCollection(UserId userId, MessageCollection msgCollection, SecurityToken token) throws ProtocolException { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "this functionality is not yet available"); }
@Test public void testRestHandler_serviceDoesntExist() { RestHandler restHandler = registry.getRestHandler("/makebelieve", "GET"); try { Future<?> future = restHandler.execute(Maps.<String, String[]>newHashMap(), null, null, null); future.get(); fail("Expect exception for missing method"); } catch (ExecutionException t) { assertSame(t.getCause().getClass(), ProtocolException.class); Assert.assertEquals(HttpServletResponse.SC_NOT_IMPLEMENTED, ((ProtocolException) t.getCause()).getCode()); } catch (Throwable t) { fail("Unexpected exception " + t.toString()); } }
protected ResponseItem responseItemFromException(Throwable t) { if (t instanceof ProtocolException) { ProtocolException pe = (ProtocolException) t; if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "responseItemFromException", MessageKeys.API_SERVLET_PROTOCOL_EXCEPTION,pe); } return new ResponseItem(pe.getCode(), pe.getMessage(), pe.getResponse()); } if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "responseItemFromException", MessageKeys.API_SERVLET_EXCEPTION,t); } return new ResponseItem(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); }
public ProtocolException(int errorCode, String errorMessage, Object response) { super(errorMessage); checkErrorCode(errorCode); this.errorCode = errorCode; this.response = response; }
/** {@inheritDoc} */ public Future<Void> modifyMessage(UserId userId, String msgCollId, String messageId, Message message, SecurityToken token) throws ProtocolException { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "this functionality is not yet available"); }
@Test public void testRpcHandler_serviceDoesntExist() throws Exception { JSONObject rpc = new JSONObject("{method : makebelieve.get}"); RpcHandler rpcHandler = registry.getRpcHandler(rpc); try { Future<?> future = rpcHandler.execute(null, null, null); future.get(); fail("Expect exception for missing method"); } catch (ExecutionException t) { assertSame(t.getCause().getClass(), ProtocolException.class); Assert.assertEquals(HttpServletResponse.SC_NOT_IMPLEMENTED, ((ProtocolException) t.getCause()).getCode()); } catch (Throwable t) { fail("Unexpected exception " + t.toString()); } }
protected ResponseItem responseItemFromException(Throwable t) { if (t instanceof ProtocolException) { ProtocolException pe = (ProtocolException) t; if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "responseItemFromException", MessageKeys.API_SERVLET_PROTOCOL_EXCEPTION,pe); } return new ResponseItem(pe.getCode(), pe.getMessage(), pe.getResponse()); } if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "responseItemFromException", MessageKeys.API_SERVLET_EXCEPTION,t); } return new ResponseItem(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage()); }