List of usage examples for com.google.gwt.http.client Response SC_NOT_FOUND
int SC_NOT_FOUND
To view the source code for com.google.gwt.http.client Response SC_NOT_FOUND.
Click Source Link
From source file:com.ait.tooling.nativetools.client.rpc.JSONCommandRequest.java
License:Open Source License
protected void onBadStatusCode(final RequestBuilder builder, final String command, final long counter, final long reqtime, final AsyncCallback<NObject> callback, final int code) { if (Response.SC_NOT_FOUND == code) { doFailure(command, callback, counter, reqtime, new Exception("Code [" + code + "]: Command [" + command + "] not found ")); } else if (Response.SC_FORBIDDEN == code) { doFailure(command, callback, counter, reqtime, new Exception("Code [" + code + "]: No permission or Session expired")); } else if (Response.SC_BAD_GATEWAY == code) { doFailure(command, callback, counter, reqtime, new Exception("Code [" + code + "]: Misconfigured Gateway")); } else if ((0 == code) || (Response.SC_SERVICE_UNAVAILABLE == code)) { doFailure(command, callback, counter, reqtime, new Exception("Code [" + code + "]: Server appears to be down")); } else {/*w w w.j av a2s.c o m*/ doFailure(command, callback, counter, reqtime, new Exception("Bad status code ]" + code + "] for command [" + command + "]")); } }
From source file:com.google.collide.client.communication.FrontendRestApi.java
License:Open Source License
private static FailureReason getFailureReason(Response response, ServerError responseData) { switch (response.getStatusCode()) { case Response.SC_OK: return null; case Response.SC_UNAUTHORIZED: if (responseData != null) { return responseData.getFailureReason(); }/* w w w.j a v a 2s . c o m*/ return FailureReason.UNAUTHORIZED; // TODO: Make this a server dto error. case Response.SC_CONFLICT: return FailureReason.STALE_CLIENT; case Response.SC_NOT_FOUND: if (responseData != null) { return responseData.getFailureReason(); } return FailureReason.UNKNOWN; case Response.SC_NOT_IMPLEMENTED: if (responseData != null) { return responseData.getFailureReason(); } return FailureReason.UNKNOWN; default: return FailureReason.SERVER_ERROR; } }
From source file:com.google.gerrit.client.rpc.RestApi.java
License:Apache License
/** True if err is a StatusCodeException reporting Not Found. */ public static boolean isNotFound(Throwable err) { return isStatus(err, Response.SC_NOT_FOUND); }
From source file:com.vaadin.client.communication.DefaultConnectionStateHandler.java
License:Apache License
@Override public void heartbeatInvalidStatusCode(Request request, Response response) { int statusCode = response.getStatusCode(); getLogger().warning("Heartbeat request returned " + statusCode); if (response.getStatusCode() == Response.SC_GONE) { // Session expired getConnection().showSessionExpiredError(null); stopApplication();// ww w . j ava2 s. co m } else if (response.getStatusCode() == Response.SC_NOT_FOUND) { // UI closed, do nothing as the UI will react to this // Should not trigger reconnect dialog as this will prevent user // input } else { handleRecoverableError(Type.HEARTBEAT, null); } }
From source file:nl.sense_os.commonsense.login.client.forgotpassword.ForgotPasswordActivity.java
License:Open Source License
private void onForgotPasswordResponse(Response response) { if (Response.SC_OK == response.getStatusCode()) { onForgotRequestSuccess();/*w w w . ja va 2s .c om*/ } else if (Response.SC_NOT_FOUND == response.getStatusCode()) { onUserNotFound(); } else { onForgotPasswordFailure(response.getStatusCode(), new Throwable(response.getStatusText())); } }
From source file:org.glom.web.server.OnlineGlomImagesServlet.java
License:Open Source License
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { //These match the history token keys in DetailsPlace: final String attrDocumentID = StringUtils.defaultString(req.getParameter("document")); final String attrTableName = StringUtils.defaultString(req.getParameter("table")); final String attrPrimaryKeyValue = StringUtils.defaultString(req.getParameter("value")); final String attrFieldName = StringUtils.defaultString(req.getParameter("field")); //To request a static LayoutItemImage from the document //instead of from the database: final String attrLayoutName = StringUtils.defaultString(req.getParameter("layout")); final String attrLayoutPath = StringUtils.defaultString(req.getParameter("layoutpath")); if (StringUtils.isEmpty(attrDocumentID)) { doError(resp, Response.SC_NOT_FOUND, "No document ID was specified."); return;/*www. j av a 2 s . c o m*/ } if (!isAuthenticated(req, attrDocumentID)) { doError(resp, Response.SC_NOT_FOUND, "No access to the document.", attrDocumentID); return; } if (StringUtils.isEmpty(attrTableName)) { doError(resp, Response.SC_NOT_FOUND, "No table name was specified.", attrDocumentID); return; } //TODO: Is it from the database or is it a static LayouteItemText from the document. final boolean fromDb = !StringUtils.isEmpty(attrPrimaryKeyValue); final boolean fromLayout = !StringUtils.isEmpty(attrLayoutName); if (!fromDb && !fromLayout) { doError(resp, Response.SC_NOT_FOUND, "No primary key value or layout name was specified.", attrDocumentID); return; } if (fromDb && StringUtils.isEmpty(attrFieldName)) { doError(resp, Response.SC_NOT_FOUND, "No field name was specified.", attrDocumentID); return; } final ConfiguredDocument configuredDocument = getDocument(attrDocumentID); if (configuredDocument == null) { doError(resp, Response.SC_NOT_FOUND, "The specified document was not found.", attrDocumentID); return; } final Document document = configuredDocument.getDocument(); if (document == null) { doError(resp, Response.SC_NOT_FOUND, "The specified document details were not found.", attrDocumentID); return; } byte[] bytes = null; if (fromDb) { bytes = getImageFromDatabase(req, resp, attrDocumentID, attrTableName, attrPrimaryKeyValue, attrFieldName, configuredDocument, document); } else { bytes = getImageFromDocument(req, resp, attrDocumentID, attrTableName, attrLayoutName, attrLayoutPath, configuredDocument, document); } if (bytes == null) { doError(resp, Response.SC_NOT_FOUND, "The image bytes could not be found. Please see the earlier error.", attrDocumentID); return; } final InputStream is = new ByteArrayInputStream(bytes); final String contentType = URLConnection.guessContentTypeFromStream(is); resp.setContentType(contentType); // Set content size: resp.setContentLength((int) bytes.length); // Open the output stream: final OutputStream out = resp.getOutputStream(); // Copy the contents to the output stream out.write(bytes); out.close(); }
From source file:org.glom.web.server.OnlineGlomImagesServlet.java
License:Open Source License
/** Get the image from a specific <data_layout_text> node of a specific layout for a specific table in the document, * with no access to the database data./*from www.j a va2 s. c o m*/ * * @param resp * @param attrDocumentID * @param attrTableName * @param attrLayoutName * @param attrLayoutPath * @param configuredDocument * @param document * @return * @throws IOException */ private byte[] getImageFromDocument(final HttpServletRequest request, final HttpServletResponse resp, final String attrDocumentID, final String attrTableName, final String attrLayoutName, final String attrLayoutPath, final ConfiguredDocument configuredDocument, final Document document) throws IOException { final LayoutItem item = document.getLayoutItemByPath(attrTableName, attrLayoutName, attrLayoutPath); if (item == null) { doError(resp, Response.SC_NOT_FOUND, "The item specifed by the layout path could not be found, attrLayoutPath=" + attrLayoutPath, attrDocumentID); return null; } if (!(item instanceof LayoutItemImage)) { doError(resp, Response.SC_NOT_FOUND, "The item specifed by the layout path is not an image. It has class: " + item.getClass().getName() + " and item name=" + item.getName() + ", attrLayoutPath=" + attrLayoutPath, attrDocumentID); return null; } final LayoutItemImage image = (LayoutItemImage) item; return image.getImage().getImageData(); }
From source file:org.glom.web.server.OnlineGlomImagesServlet.java
License:Open Source License
/** Get the image from a specific field of a specific record in a specific table in the database. * /*from www .j av a 2s. c o m*/ * @param resp * @param attrDocumentID * @param attrTableName * @param attrPrimaryKeyValue * @param attrFieldName * @param configuredDocument * @param document * @return * @throws IOException */ private byte[] getImageFromDatabase(final HttpServletRequest request, final HttpServletResponse resp, final String attrDocumentID, final String attrTableName, final String attrPrimaryKeyValue, final String attrFieldName, final ConfiguredDocument configuredDocument, final Document document) throws IOException { final Field field = document.getField(attrTableName, attrFieldName); if (field == null) { doError(resp, Response.SC_NOT_FOUND, "The specified field was not found: field=" + attrFieldName, attrDocumentID); return null; } final Field fieldPrimaryKey = document.getTablePrimaryKeyField(attrTableName); TypedDataItem primaryKeyValue = new TypedDataItem(); primaryKeyValue.setNumber(Double.parseDouble(attrPrimaryKeyValue)); final LayoutItemField layoutItemField = new LayoutItemField(); layoutItemField.setFullFieldDetails(field); final List<LayoutItemField> fieldsToGet = new ArrayList<LayoutItemField>(); fieldsToGet.add(layoutItemField); final String query = SqlUtils.buildSqlSelectWithKey(attrTableName, fieldsToGet, fieldPrimaryKey, primaryKeyValue, document.getSqlDialect()); final ComboPooledDataSource authenticatedConnection = getConnection(request, attrDocumentID); if (authenticatedConnection == null) { return null; } ResultSet rs = null; try { rs = SqlUtils.executeQuery(authenticatedConnection, query); } catch (SQLException e) { doError(resp, Response.SC_INTERNAL_SERVER_ERROR, "SQL exception: " + e.getMessage(), attrDocumentID); return null; } if (rs == null) { doError(resp, Response.SC_INTERNAL_SERVER_ERROR, "The SQL result set is null.", attrDocumentID); return null; } byte[] bytes = null; try { rs.next(); bytes = rs.getBytes(1); //This is 1-indexed, not 0-indexed. } catch (SQLException e) { doError(resp, Response.SC_INTERNAL_SERVER_ERROR, "SQL exception: " + e.getMessage(), attrDocumentID); return null; } if (bytes == null) { doError(resp, Response.SC_INTERNAL_SERVER_ERROR, "The database contained null.", attrDocumentID); return null; } return bytes; }
From source file:org.obiba.opal.web.gwt.app.client.administration.configuration.edit.GeneralConfModalPresenter.java
License:Open Source License
@Override public void save() { getView().clearErrors();/* w ww. j a v a 2 s .c o m*/ if (validationHandler.validate()) { GeneralConf dto = GeneralConf.create(); dto.setName(getView().getName().getText()); dto.setDefaultCharSet(getView().getDefaultCharSet().getText()); dto.setLanguagesArray(getView().getLanguages()); dto.setPublicURL(getView().getPublicUrl().getText()); ResourceRequestBuilderFactory.<GeneralConf>newBuilder().forResource("/system/conf/general") .withResourceBody(GeneralConf.stringify(dto)).withCallback(new ResponseCodeCallback() { @Override public void onResponseCode(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { getView().hide(); fireEvent(new GeneralConfigSavedEvent()); } else { fireEvent(NotificationEvent.newBuilder().error(response.getText()).build()); } } }, Response.SC_OK, Response.SC_INTERNAL_SERVER_ERROR, Response.SC_NOT_FOUND).put().send(); } }
From source file:org.obiba.opal.web.gwt.app.client.administration.database.list.identifiers.IdentifiersDatabasePresenter.java
License:Open Source License
private void refresh() { ResourceRequestBuilderFactory.<DatabaseDto>newBuilder() // .forResource(UriBuilders.DATABASE_IDENTIFIERS.create().build()) // .withCallback(new ResourceCallback<DatabaseDto>() { @Override/*w w w .j a v a2 s . com*/ public void onResource(Response response, @Nullable DatabaseDto dto) { databaseDto = dto; getView().setDatabase(dto); } }) // .withCallback(Response.SC_NOT_FOUND, new ResponseCodeCallback() { @Override public void onResponseCode(Request request, Response response) { databaseDto = null; getView().setDatabase(null); } }).get().send(); refreshDeletionCapability(); }