use of org.pentaho.reporting.libraries.resourceloader.ResourceKeyCreationException in project pentaho-platform by pentaho.
the class PentahoResourceLoader method deriveKey.
/**
* derive a key from an existing key, used when a relative path is given.
*
* @param parent
* the parent key
* @param data
* the new data to be keyed
* @return derived key
* @throws ResourceKeyCreationException
*/
public ResourceKey deriveKey(final ResourceKey parent, final String path, final Map data) throws ResourceKeyCreationException {
if (isSupportedKey(parent) == false) {
// $NON-NLS-1$
throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
}
String resource;
if (path.startsWith("solution://")) {
resource = path;
} else if (path.startsWith("/")) {
// $NON-NLS-1$
resource = "solution:/" + path;
} else {
resource = LoaderUtils.mergePaths((String) parent.getIdentifier(), path);
// add the slash. We do need to make sure that the resource is not a url
if (!resource.startsWith(HTTP_URL_PREFIX) && !resource.startsWith(PATH_SEPARATOR)) {
resource = PATH_SEPARATOR + resource;
}
}
final Map map;
if (data != null) {
map = new HashMap();
map.putAll(parent.getFactoryParameters());
map.putAll(data);
} else {
map = parent.getFactoryParameters();
}
return new ResourceKey(parent.getSchema(), resource, map);
}
Aggregations