Package com.hbasebook.hush

Examples of com.hbasebook.hush.ResourceManager


      if (dispatcher != null) {
        dispatcher.forward(request, response);
      }
    } else {
      // otherwise assume it is a short Id
      ResourceManager rm = ResourceManager.getInstance();
      boolean isQrCode = uri.endsWith(QR_EXTENSION);
      String shortId = isQrCode ? uri.substring(1, uri.length() -
        QR_EXTENSION.length()) : uri.substring(1);
      ShortUrl surl = rm.getUrlManager().getShortUrl(shortId);
      if (surl == null) {
        // if the short Id was bogus show a "shush" (our fail whale)
        httpResponse.sendError(404);
      } else if (isQrCode) {
        // show QRCode if requested
        sendQRCode(httpResponse, surl.getLongUrl());
      } else {
        // increment counters and redirect!
        rm.getCounters().incrementUsage(shortId, new RequestInfo(httpRequest));
        String refShortId = surl.getRefShortId();
        if (refShortId != null) {
          // increment the aggregate link
          rm.getCounters().incrementUsage(refShortId,
            new RequestInfo(httpRequest));
        }
        httpResponse.sendRedirect(surl.getLongUrl());
      }
    }
View Full Code Here

TOP

Related Classes of com.hbasebook.hush.ResourceManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.