当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionCode.RESOURCE_NOT_FOUND属性代码示例

本文整理汇总了Java中org.geomajas.global.ExceptionCode.RESOURCE_NOT_FOUND属性的典型用法代码示例。如果您正苦于以下问题:Java ExceptionCode.RESOURCE_NOT_FOUND属性的具体用法?Java ExceptionCode.RESOURCE_NOT_FOUND怎么用?Java ExceptionCode.RESOURCE_NOT_FOUND使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.geomajas.global.ExceptionCode的用法示例。


在下文中一共展示了ExceptionCode.RESOURCE_NOT_FOUND属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUrl

private URL getUrl(String resourceLocation) throws LayerException {
	if (resourceLocation.startsWith(GeomajasConstant.CLASSPATH_URL_PREFIX)) {
		resourceLocation = resourceLocation.substring(GeomajasConstant.CLASSPATH_URL_PREFIX.length());
	}
	Resource resource = applicationContext.getResource(resourceLocation);
	try {
		if (resource.exists()) {
			return resource.getURL();
		} else {
			String gwtResource = GeomajasConstant.CLASSPATH_URL_PREFIX + resourceLocation;
			Resource[] matching = applicationContext.getResources(gwtResource);
			if (matching.length > 0) {
				return matching[0].getURL();
			} else {
				log.warn(MISSING_RESOURCE, gwtResource);
				throw new LayerException(ExceptionCode.RESOURCE_NOT_FOUND, gwtResource);
			}
		}
	} catch (IOException e) {
		log.warn(MISSING_RESOURCE, resourceLocation);
		throw new LayerException(e, ExceptionCode.RESOURCE_NOT_FOUND, resourceLocation);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:23,代码来源:StyleConverterServiceImpl.java

示例2: getImage

private BufferedImage getImage(String href) throws GeomajasException {
	InputStream is = null;
	try {
		Resource resource = resourceService.find(href);
		if (resource != null) {
			is = resource.getInputStream();
		} else {
			// backwards compatibility
			resource = resourceService.find("images/" + href);
			if (null == resource) {
				resource = resourceService.find("image/" + href);
			}
			if (resource != null) {
				is = resource.getInputStream();
			} else {
				is = ClassLoader.getSystemResourceAsStream(href);
			}
		}
		if (is == null) {
			throw new GeomajasException(ExceptionCode.RESOURCE_NOT_FOUND, href);
		}
		return ImageIO.read(is);
	} catch (IOException io) {
		throw new GeomajasException(io, ExceptionCode.RESOURCE_NOT_FOUND, href);
	} finally {
		if (is != null) {
			try {
				is.close();
			} catch (IOException e) {
				// ignore
			}
		}
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:34,代码来源:LegendGraphicServiceImpl.java

示例3: find

@Override
public Resource find(String location) throws GeomajasException {
	Resource resource = applicationContext.getResource(location);
	if (resource.exists()) {
		return resource;
	} else {
		String cpResource;
		if (location.startsWith("/")) {
			cpResource = GeomajasConstant.CLASSPATH_URL_PREFIX + location.substring(1);
		} else {
			cpResource = GeomajasConstant.CLASSPATH_URL_PREFIX + location;
		}
		resource = applicationContext.getResource(cpResource);
		if (resource.exists()) {
			return resource;
		} else {
			for (String root : rootPaths) {
				if (root.endsWith("/")) {
					resource = applicationContext.getResource(root + location);
				} else {
					resource = applicationContext.getResource(root + "/" + location);
				}
				if (resource.exists()) {
					return resource;
				}
			}
			throw new GeomajasException(ExceptionCode.RESOURCE_NOT_FOUND, location);
		}
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:30,代码来源:ResourceServiceImpl.java


注:本文中的org.geomajas.global.ExceptionCode.RESOURCE_NOT_FOUND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。