{
throw new NullPointerException();
}
final ResourceKey contentBase = element.getContentBase();
if (contentBase == null)
{
// treat all resources as linked resources ..
AbstractElementWriteHandler.logger.debug("No content base, treating all content as linked.");
return;
}
final ResourceKey defSource = element.getDefinitionSource();
if (defSource == null)
{
// treat all resources as linked resources ..
AbstractElementWriteHandler.logger.debug("No report definition source, treating all content as linked.");
return;
}
if (ObjectUtilities.equal(contentBase.getParent(), defSource.getParent()) == false)
{
// treat all resources as linked resources ..
AbstractElementWriteHandler.logger.debug(
"Content base points to non-bundle location, treating all content as linked.");
return;
}
final Object contentBasePathRaw = contentBase.getIdentifier();
if (contentBasePathRaw instanceof String == false)
{
return;
}
final String contentBasePath = String.valueOf(contentBasePathRaw);
final ResourceManager resourceManager = state.getMasterReport().getResourceManager();
final ElementType type = element.getElementType();
final ElementMetaData data = type.getMetaData();
final AttributeMetaData[] datas = data.getAttributeDescriptions();
for (int i = 0; i < datas.length; i++)
{
final AttributeMetaData attributeMetaData = datas[i];
if (attributeMetaData.isTransient())
{
continue;
}
if (isFiltered(attributeMetaData))
{
continue;
}
final Object attValue = element.getAttribute(attributeMetaData.getNameSpace(), attributeMetaData.getName());
if (attValue == null)
{
continue;
}
final ResourceReference[] referencedResources = attributeMetaData.getReferencedResources
(element, state.getMasterReport().getResourceManager(), attValue);
for (int j = 0; j < referencedResources.length; j++)
{
final ResourceReference reference = referencedResources[j];
if (reference.isLinked())
{
AbstractElementWriteHandler.logger.debug("Linked Resource will not be copied into bundle: " + reference);
continue;
}
final ResourceKey path = reference.getPath();
final Object identifier = path.getIdentifier();
if (identifier instanceof String == false)
{
AbstractElementWriteHandler.logger.warn("Resource-Bundle-Key has no parseable path: " + path);
continue;
}