Java Code Examples for com.google.gwt.http.client.Response.SC_NOT_FOUND

The following are Jave code examples for showing how to use SC_NOT_FOUND of the com.google.gwt.http.client.Response class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: gerrit   File: RestApi.java   View Source Code Vote up 6 votes
/** Is the Gerrit Code Review server likely to return this status? */
public static boolean isExpected(int statusCode) {
  switch (statusCode) {
    case SC_UNAVAILABLE:
    case Response.SC_BAD_REQUEST:
    case Response.SC_UNAUTHORIZED:
    case Response.SC_FORBIDDEN:
    case Response.SC_NOT_FOUND:
    case Response.SC_METHOD_NOT_ALLOWED:
    case Response.SC_CONFLICT:
    case Response.SC_PRECONDITION_FAILED:
    case 422: // Unprocessable Entity
    case 429: // Too Many Requests (RFC 6585)
      return true;

    default:
      // Assume any other code is not expected. These may be
      // local proxy server errors outside of our control.
      return false;
  }
}
 
Example 2
Project: sigmah   File: FileServlet.java   View Source Code Vote up 6 votes
/**
 * See {@link ServletMethod#DOWNLOAD_LOGO} for JavaDoc.
 * 
 * @param request
 *          The HTTP request containing the file id parameter.
 * @param response
 *          The HTTP response on which the file content is written.
 * @param context
 *          The execution context.
 * @throws Exception
 *           If an error occurs during process.
 */
protected void downloadLogo(final HttpServletRequest request, final HttpServletResponse response, final ServletExecutionContext context) throws Exception {

	// Retrieves the file id.
	final String id = getParameter(request, RequestParameter.ID, false);

	if (LOG.isDebugEnabled()) {
		LOG.debug("Downloads logo with id '{}'.", id);
	}

	try {

		downloadBase64(id, fileStorageProvider.open(id), response);

	} catch (final NoSuchFileException e) {
		if (LOG.isInfoEnabled()) {
			LOG.info("No logo found for id '" + id + "'.", e);
		}
		throw new StatusServletException(Response.SC_NOT_FOUND, e);
	}
}
 
Example 3
Project: sigmah   File: FileServlet.java   View Source Code Vote up 6 votes
/**
 * See {@link ServletMethod#DOWNLOAD_ARCHIVE} for JavaDoc.
 * 
 * @param request
 *          The HTTP request containing the file id parameter.
 * @param response
 *          The HTTP response on which the file content is written.
 * @param context
 *          The execution context.
 * @throws Exception
 *           If an error occurs during process.
 */
protected void downloadArchive(final HttpServletRequest request, final HttpServletResponse response, final ServletExecutionContext context) throws Exception {

	// Retrieves the file id.
	final String id = getParameter(request, RequestParameter.ID, false);

	if (LOG.isDebugEnabled()) {
		LOG.debug("Downloads archive with id '{}'.", id);
	}

	try {

		download(id, backupArchiveManager.open(id), response);

	} catch (final NoSuchFileException e) {
		if (LOG.isInfoEnabled()) {
			LOG.info("No archive found for id '" + id + "'.", e);
		}
		throw new StatusServletException(Response.SC_NOT_FOUND, e);
	}
}
 
Example 4
Project: sigmah   File: FileServlet.java   View Source Code Vote up 4 votes
/**
 * See {@link ServletMethod#DOWNLOAD_FILE} for JavaDoc.
 * 
 * @param request
 *          The HTTP request containing the file id parameter.
 * @param response
 *          The HTTP response on which the file content is written.
 * @param context
 *          The execution context.
 * @throws Exception
 *           If an error occurs during process.
 */
protected void downloadFile(final HttpServletRequest request, final HttpServletResponse response, final ServletExecutionContext context) throws Exception {

	// Retrieves the file version id.
	final Integer fileVersionId = getIntegerParameter(request, RequestParameter.ID, false);

	LOG.debug("Downloads file with version id '{}'.", fileVersionId);

	try {

		final FileVersion version = fileDAO.getVersion(fileVersionId);

		final String name = version.getName() + '.' + version.getExtension();
		final String path = version.getPath();

		download(path, name, fileStorageProvider.open(path), response);

	} catch (final NoSuchFileException e) {
		LOG.info("No file found for version id '" + fileVersionId + "'.", e);
		throw new StatusServletException(Response.SC_NOT_FOUND, e);
	}
}