congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
FileLfsServlet
Code IndexAdd Tabnine to your IDE (free)

How to use
FileLfsServlet
in
org.eclipse.jgit.lfs.server.fs

Best Java code snippets using org.eclipse.jgit.lfs.server.fs.FileLfsServlet (Showing top 10 results out of 315)

origin: org.eclipse.jgit/org.eclipse.jgit.lfs.server

  /**
   * {@inheritDoc}
   *
   * Handle errors
   */
  @Override
  public void onError(Throwable e) {
    try {
      FileLfsServlet.sendError(response,
          HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage());
      context.complete();
      in.close();
    } catch (IOException ex) {
      LOG.log(Level.SEVERE, ex.getMessage(), ex);
    }
  }
}
origin: org.eclipse.jgit/org.eclipse.jgit.lfs.server

/**
 * {@inheritDoc}
 *
 * Handle object downloads
 */
@Override
protected void doGet(HttpServletRequest req,
    HttpServletResponse rsp) throws ServletException, IOException {
  AnyLongObjectId obj = getObjectToTransfer(req, rsp);
  if (obj != null) {
    if (repository.getSize(obj) == -1) {
      sendError(rsp, HttpStatus.SC_NOT_FOUND, MessageFormat
          .format(LfsServerText.get().objectNotFound,
              obj.getName()));
      return;
    }
    AsyncContext context = req.startAsync();
    context.setTimeout(timeout);
    rsp.getOutputStream()
        .setWriteListener(new ObjectDownloadListener(repository,
            context, rsp, obj));
  }
}
origin: org.eclipse.jgit/org.eclipse.jgit.lfs.server

/**
 * {@inheritDoc}
 *
 * Handle object uploads
 */
@Override
protected void doPut(HttpServletRequest req,
    HttpServletResponse rsp) throws ServletException, IOException {
  AnyLongObjectId id = getObjectToTransfer(req, rsp);
  if (id != null) {
    AsyncContext context = req.startAsync();
    context.setTimeout(timeout);
    req.getInputStream().setReadListener(new ObjectUploadListener(
        repository, context, req, rsp, id));
  }
}
origin: sonia.jgit/org.eclipse.jgit.lfs.server

/**
 * Handles object downloads
 *
 * @param req
 *            servlet request
 * @param rsp
 *            servlet response
 * @throws ServletException
 *             if a servlet-specific error occurs
 * @throws IOException
 *             if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest req,
    HttpServletResponse rsp) throws ServletException, IOException {
  AnyLongObjectId obj = getObjectToTransfer(req, rsp);
  if (obj != null) {
    if (repository.getSize(obj) == -1) {
      sendError(rsp, HttpStatus.SC_NOT_FOUND, MessageFormat
          .format(LfsServerText.get().objectNotFound,
              obj.getName()));
      return;
    }
    AsyncContext context = req.startAsync();
    context.setTimeout(timeout);
    rsp.getOutputStream()
        .setWriteListener(new ObjectDownloadListener(repository,
            context, rsp, obj));
  }
}
origin: sonia.jgit/org.eclipse.jgit.lfs.server

/**
 * Handle object uploads
 *
 * @param req
 *            servlet request
 * @param rsp
 *            servlet response
 * @throws ServletException
 *             if a servlet-specific error occurs
 * @throws IOException
 *             if an I/O error occurs
 */
@Override
protected void doPut(HttpServletRequest req,
    HttpServletResponse rsp) throws ServletException, IOException {
  AnyLongObjectId id = getObjectToTransfer(req, rsp);
  if (id != null) {
    AsyncContext context = req.startAsync();
    context.setTimeout(timeout);
    req.getInputStream().setReadListener(new ObjectUploadListener(
        repository, context, req, rsp, id));
  }
}
origin: sonia.jgit/org.eclipse.jgit.lfs.server

  /**
   * Handle errors
   *
   * @param e
   *            the cause
   */
  @Override
  public void onError(Throwable e) {
    try {
      FileLfsServlet.sendError(response,
          HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage());
      context.complete();
      in.close();
    } catch (IOException ex) {
      LOG.log(Level.SEVERE, ex.getMessage(), ex);
    }
  }
}
origin: sonia.jgit/org.eclipse.jgit.lfs.server

private AnyLongObjectId getObjectToTransfer(HttpServletRequest req,
    HttpServletResponse rsp) throws IOException {
  String info = req.getPathInfo();
  int length = 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH;
  if (info.length() != length) {
    sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, MessageFormat
        .format(LfsServerText.get().invalidPathInfo, info));
    return null;
  }
  try {
    return LongObjectId.fromString(info.substring(1, length));
  } catch (InvalidLongObjectIdException e) {
    sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, e.getMessage());
    return null;
  }
}
origin: org.eclipse.jgit/org.eclipse.jgit.lfs.server

  /** {@inheritDoc} */
  @Override
  public void onError(Throwable e) {
    try {
      out.abort();
      inChannel.close();
      channel.close();
      int status;
      if (e instanceof CorruptLongObjectException) {
        status = HttpStatus.SC_BAD_REQUEST;
        LOG.log(Level.WARNING, e.getMessage(), e);
      } else {
        status = HttpStatus.SC_INTERNAL_SERVER_ERROR;
        LOG.log(Level.SEVERE, e.getMessage(), e);
      }
      FileLfsServlet.sendError(response, status, e.getMessage());
    } catch (IOException ex) {
      LOG.log(Level.SEVERE, ex.getMessage(), ex);
    }
  }
}
origin: sonia.jgit/org.eclipse.jgit.lfs.server

  /**
   * @param e
   *            the exception that caused the problem
   */
  @Override
  public void onError(Throwable e) {
    try {
      out.abort();
      inChannel.close();
      channel.close();
      int status;
      if (e instanceof CorruptLongObjectException) {
        status = HttpStatus.SC_BAD_REQUEST;
        LOG.log(Level.WARNING, e.getMessage(), e);
      } else {
        status = HttpStatus.SC_INTERNAL_SERVER_ERROR;
        LOG.log(Level.SEVERE, e.getMessage(), e);
      }
      FileLfsServlet.sendError(response, status, e.getMessage());
    } catch (IOException ex) {
      LOG.log(Level.SEVERE, ex.getMessage(), ex);
    }
  }
}
origin: org.eclipse.jgit/org.eclipse.jgit.lfs.server

/**
 * Retrieve object id from request
 *
 * @param req
 *            servlet request
 * @param rsp
 *            servlet response
 * @return object id, or <code>null</code> if the object id could not be
 *         retrieved
 * @throws java.io.IOException
 *             if an I/O error occurs
 * @since 4.6
 */
protected AnyLongObjectId getObjectToTransfer(HttpServletRequest req,
    HttpServletResponse rsp) throws IOException {
  String info = req.getPathInfo();
  int length = 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH;
  if (info.length() != length) {
    sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, MessageFormat
        .format(LfsServerText.get().invalidPathInfo, info));
    return null;
  }
  try {
    return LongObjectId.fromString(info.substring(1, length));
  } catch (InvalidLongObjectIdException e) {
    sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, e.getMessage());
    return null;
  }
}
org.eclipse.jgit.lfs.server.fsFileLfsServlet

Javadoc

Servlet supporting upload and download of large objects as defined by the GitHub Large File Storage extension API extending git to allow separate storage of large files (https://github.com/github/git-lfs/tree/master/docs/api).

Most used methods

  • getObjectToTransfer
    Retrieve object id from request
  • sendError
    Send an error response.

Popular in Java

  • Finding current android device location
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (Timer)
  • requestLocationUpdates (LocationManager)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JButton (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now