final String path,
final Map<? extends ParameterKey, ? extends Object> factoryKeys) throws ResourceKeyCreationException
{
if (isSupportedKey(parent) == false)
{
throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
}
final String entry;
final String identifier = (String) parent.getIdentifier();
if (path != null)
{
if (path.length() > 0 && path.charAt(0) == '/')
{
entry = LoaderUtils.stripLeadingSlashes(path);
}
else
{
entry = LoaderUtils.mergePaths(identifier, path);
}
}
else
{
entry = identifier;
}
final Map<ParameterKey, Object> map;
if (factoryKeys != null)
{
map = new HashMap<ParameterKey, Object>();
map.putAll(parent.getFactoryParameters());
map.putAll(factoryKeys);
}
else
{
map = parent.getFactoryParameters();
}
if ("true".equals(LibDocBundleBoot.getInstance().getGlobalConfig().getConfigProperty
("org.pentaho.reporting.libraries.docbundle.bundleloader.directory.StrictKeyCheck", "true")))
{
try
{
final FileRepository repository = (FileRepository)
parent.getFactoryParameters().get(new FactoryParameterKey("repository"));
if (RepositoryUtilities.isExistsEntity(repository, RepositoryUtilities.split(entry, "/")) == false)
{
throw new ResourceKeyCreationException("The key does not exist: " + entry);
}
}
catch (ContentIOException e)
{
throw new ResourceKeyCreationException("Failed to check for existing key", e);
}
}
return new ResourceKey(parent.getParent(), parent.getSchema(), entry, map);
}