Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: client/tools/dartserver/java/com/google/appstack/tools/ThumbnailServlet.java

Issue 8341078: Archive dartserver code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/tools/dartserver/java/com/google/appstack/tools/ThumbnailServlet.java
diff --git a/client/tools/dartserver/java/com/google/appstack/tools/ThumbnailServlet.java b/client/tools/dartserver/java/com/google/appstack/tools/ThumbnailServlet.java
deleted file mode 100644
index fe08241a8dfe9323223482aa4f2755a5e55a6bfc..0000000000000000000000000000000000000000
--- a/client/tools/dartserver/java/com/google/appstack/tools/ThumbnailServlet.java
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.google.appstack.tools;
-
-import java.net.URL;
-import java.net.URLDecoder;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-// TODO(rnystrom): Get rid of one of the subclasses of this and just have a
-// single way to make thumbnails once we've got our server stuff figured out.
-/**
- * This servlet takes images URLs and replies with a resized thumbnail of the
- * image. Relies on the subclass to provide the actual image resizing.
- */
-public abstract class ThumbnailServlet extends HttpServlet {
- // TODO(rnystrom): Allow passing this in as a URL parameter.
- private static final int THUMBNAIL_SIZE = 156;
-
- private static Logger logger =
- Logger.getLogger(ThumbnailServlet.class.getName());
-
- @Override
- public void service(HttpServletRequest request, HttpServletResponse response) {
- String imageParam = request.getParameter("i");
- if (imageParam == null) {
- // TODO(rnystrom): Handle errors better.
- throw new RuntimeException("Must have an 'i' parameter.");
- }
-
- try {
- URL originalUrl = new URL(URLDecoder.decode(imageParam, "UTF-8"));
-
- byte[] data = makeThumbnail(originalUrl, THUMBNAIL_SIZE, THUMBNAIL_SIZE);
-
- // Serve up the thumbnail.
- response.setContentType("image/jpeg");
- response.getOutputStream().write(data);
- } catch (Exception e) {
- // TODO(rnystrom): Handle errors better.
- logger.log(Level.SEVERE, "Got error serving thumbnail.", e);
- }
- }
-
- /**
- * Override this to read the original image at that URL, scale it to a
- * thumbnail and return the raw data for a thumbnail PNG.
- *
- * @param originalUrl URL of the source image to create a thumbnail for.
- * @return Raw data for a PNG-formatted thumbnail image.
- */
- protected abstract byte[] makeThumbnail(URL originalUrl, int width, int height);
-}

Powered by Google App Engine
This is Rietveld 408576698