Exemplo n.º 1
0
 private boolean workaroundBug356918(
     HttpServletRequest request, HttpServletResponse response, Exception e)
     throws ServletException, JSONException {
   if (e instanceof CheckoutConflictException) {
     JSONObject result = new JSONObject();
     result.put(GitConstants.KEY_RESULT, MergeStatus.FAILED.name());
     Map<String, MergeFailureReason> failingPaths = new HashMap<String, MergeFailureReason>();
     String[] files = e.getMessage().split("\n"); // $NON-NLS-1$
     for (int i = 1; i < files.length; i++) {
       // TODO: this is not always true, but it's a temporary workaround
       failingPaths.put(files[i], MergeFailureReason.DIRTY_WORKTREE);
     }
     result.put(GitConstants.KEY_FAILING_PATHS, failingPaths);
     try {
       OrionServlet.writeJSONResponse(
           request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
       return true;
     } catch (IOException e1) {
       e = e1;
     }
   }
   return statusHandler.handleRequest(
       request,
       response,
       new ServerStatus(
           IStatus.ERROR,
           HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
           "An error occured when merging.",
           e.getCause()));
 }
 private String readPatch(ServletInputStream requestStream, String contentType)
     throws IOException {
   // fast forward stream past multi-part header
   int boundaryOff = contentType.indexOf("boundary="); // $NON-NLS-1$
   String boundary =
       contentType.substring(
           boundaryOff + "boundary=".length(), contentType.length()); // $NON-NLS-1$
   Map<String, String> parts = IOUtilities.parseMultiPart(requestStream, boundary);
   if ("fileRadio".equals(parts.get("radio"))) // $NON-NLS-1$ //$NON-NLS-2$
   return parts.get("uploadedfile"); // $NON-NLS-1$
   if ("urlRadio".equals(parts.get("radio"))) // $NON-NLS-1$ //$NON-NLS-2$
   return fetchPatchContentFromUrl(parts.get("url")); // $NON-NLS-1$
   return null;
 }