public Conveyor getConveyor(HttpServletRequest request, HttpServletResponse response) throws GeoWebCacheException, OWSException { throw new ServiceException( "Service for " + pathName + " needs to override " + "getConveyor(HttpSerlvetRequest,HttpServletResponse)"); }
public void testText() throws Exception { OWSException xssExceptionText = new OWSException(httpCode, exceptionCode, "locator", textToEncode); assertTrue(isXmlEncoded(xssExceptionText)); }
/** Helper method that performs CITE tests mandatory validations. */ private static void performCiteValidation(HttpServletRequest request) throws OWSException { // paths validation are not done for WMTS REST API if (isRestRequest(request)) { return; } // base path should end with WMTS String basePath = request.getPathInfo(); String[] paths = basePath.split("/"); String lastPath = paths[paths.length - 1]; if (!lastPath.equalsIgnoreCase("WMTS")) { // invalid base path, not found should be returned throw new OWSException( 404, "NoApplicableCode", "request", "Service or request not found"); } // service query parameter is mandatory and should be equal to WMTS validateWmtsServiceName("wmts", request); }
/** * Intercepts the {@code getConveyor} and {@code handleRequest} calls to a {@link Service} * instance and checks whether the service is enabled. * * @see * org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) */ public Object invoke(final MethodInvocation invocation) throws Throwable { final String methodName = invocation.getMethod().getName(); if ("getConveyor".equals(methodName) || "handleRequest".equals(methodName)) { final org.geowebcache.service.Service service = (Service) invocation.getThis(); boolean serviceEnabled; if (service.getPathName().equals("wmts")) { serviceEnabled = geoServer.getService(WMTSInfo.class).isEnabled(); } else { serviceEnabled = gwcFacade.isServiceEnabled(service); } if (!serviceEnabled) { throw new org.geowebcache.service.HttpErrorCodeException( 400, "Service is disabled"); } } return invocation.proceed(); } }
/** * @param namePfx * @param overlayXml * @param dataXml * @param response * @return * @throws ServiceException */ protected static byte[] createZippedKML( String namePfx, String formatExtension, byte[] overlayXml, Resource dataXml) throws ServiceException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { writeZippedKML(namePfx, formatExtension, overlayXml, dataXml, out); } catch (IOException ioe) { throw new ServiceException("Encountered problem writing zip: " + ioe.getMessage()); } return out.toByteArray(); }
public boolean isServiceEnabled(final Service service) { return getConfig().isEnabled(service.getPathName()); }
String requestedServiceName = getParameterValue("SERVICE", request); if (requestedServiceName == null) { throw new OWSException( 400, "MissingParameterValue", throw new OWSException( 400, "InvalidParameterValue",
/** * Intercepts the {@code getConveyor} and {@code handleRequest} calls to a {@link Service} * instance and checks whether the service is enabled. * * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) */ public Object invoke(final MethodInvocation invocation) throws Throwable { final String methodName = invocation.getMethod().getName(); if ("getConveyor".equals(methodName) || "handleRequest".equals(methodName)) { final org.geowebcache.service.Service service = (Service) invocation.getThis(); if (!gwcFacade.isServiceEnabled(service)) { throw new org.geowebcache.service.HttpErrorCodeException(400, "Service is disabled"); } } return invocation.proceed(); }
public Resource getResponse() { return new ByteArrayResource(this.toString().getBytes()); }
/** * Convert Google's tiling coordinates into an {x,y,x} * * see http://code.google.com/apis/maps/documentation/overlays.html#Custom_Map_Types * * @param quadKey * @return */ public static long[] convert(long zoomLevel, long x, long y) throws ServiceException { // Extent is the total number of tiles in y direction long extent = (long) Math.pow(2, zoomLevel); if (x < 0 || x > extent - 1) { throw new ServiceException("The X coordinate is not sane: " + x); } if (y < 0 || y > extent - 1) { throw new ServiceException("The Y coordinate is not sane: " + y); } // xPos and yPos correspond to the top left hand corner long[] gridLoc = { x, extent - y - 1, zoomLevel }; return gridLoc; } }
/** * * * @param namePfx * @param overlayXml * @param dataXml * @param response * @return * @throws ServiceException */ protected static byte[] createZippedKML( String namePfx , String formatExtension, byte[] overlayXml, Resource dataXml) throws ServiceException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { writeZippedKML(namePfx, formatExtension, overlayXml, dataXml, out); } catch (IOException ioe) { throw new ServiceException( "Encountered problem writing zip: " + ioe.getMessage()); } return out.toByteArray(); }
public void testLocator() throws Exception { OWSException xssExceptionLocator = new OWSException(httpCode, exceptionCode, textToEncode, "exceptionText"); assertTrue(isXmlEncoded(xssExceptionLocator)); }
public boolean isServiceEnabled(final Service service) { return getConfig().isEnabled(service.getPathName()); }
private boolean isXmlEncoded(OWSException exception) throws Exception { // We should find the text to test back as an encoded string. String text = exception.toString(); String encoded = Encode.forXml(textToEncode); return text.contains(encoded); } }
/** * Convert Google's tiling coordinates into an {x,y,x} * * <p>see http://code.google.com/apis/maps/documentation/overlays.html#Custom_Map_Types * * @param zoomLevel * @param x * @param y * @return */ public static long[] convert(long zoomLevel, long x, long y) throws ServiceException { // Extent is the total number of tiles in y direction long extent = (long) Math.pow(2, zoomLevel); if (x < 0 || x > extent - 1) { throw new ServiceException("The X coordinate is not sane: " + x); } if (y < 0 || y > extent - 1) { throw new ServiceException("The Y coordinate is not sane: " + y); } // xPos and yPos correspond to the top left hand corner long[] gridLoc = {x, extent - y - 1, zoomLevel}; return gridLoc; } }
throw new ServiceException("Zoomlevel cannot be greater than 17 for Mobile GMaps"); throw new ServiceException("The X coordinate is not sane: " + x); throw new ServiceException("The Y coordinate is not sane: " + y);
throw new ServiceException("Zoomlevel cannot be greater than 17 for Mobile GMaps"); throw new ServiceException("The X coordinate is not sane: " + x); throw new ServiceException("The Y coordinate is not sane: " + y);
protected String getLayersParameter(HttpServletRequest request) throws ServiceException { String layers = ServletUtils.stringFromMap( request.getParameterMap(), request.getCharacterEncoding(), "layers"); if (layers == null) { throw new ServiceException("Unable to parse layers parameter from request."); } return layers; }
protected static long[] parseGridLocString(String key) throws ServiceException { // format should be x<x>y<y>z<z> long[] ret = {-1, -1, -1}; int yloc = key.indexOf("y"); int zloc = key.indexOf("z"); if (yloc < 2 || zloc < 4) { return ret; } try { ret[0] = Long.parseLong(key.substring(1, yloc)); ret[1] = Long.parseLong(key.substring(yloc + 1, zloc)); ret[2] = Long.parseLong(key.substring(zloc + 1, key.length())); } catch (NumberFormatException nfe) { throw new ServiceException("Unable to parse " + key); } catch (StringIndexOutOfBoundsException sobe) { throw new ServiceException("Unable to parse " + key); } return ret; }
protected static long[] parseGridLocString(String key) throws ServiceException { // format should be x<x>y<y>z<z> long[] ret = { -1, -1, -1 }; int yloc = key.indexOf("y"); int zloc = key.indexOf("z"); if (yloc < 2 || zloc < 4) { return ret; } try { ret[0] = Long.parseLong(key.substring(1, yloc)); ret[1] = Long.parseLong(key.substring(yloc + 1, zloc)); ret[2] = Long.parseLong(key.substring(zloc + 1, key.length())); } catch (NumberFormatException nfe) { throw new ServiceException("Unable to parse " + key); } catch (StringIndexOutOfBoundsException sobe) { throw new ServiceException("Unable to parse " + key); } return ret; }