本文整理汇总了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);
}
}
示例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
}
}
}
}
示例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);
}
}
}