logger.error("Component and/or component composite filepath cannot be null");
throw new IllegalArgumentException(
"Component and/or component composite filepath/metadata extension cannot be null");
}
Component compositeComponent = null;
if (Utils.isNotEmpty(component.getCompositeMetadataFilePath())) {
compositeComponent = getComponentByFilePath(component.getCompositeMetadataFilePath());
} else {
compositeComponent = getComponentByExtension(component.getMetadataFileExtension());
}
if (compositeComponent == null) {
throw new FactoryException("Unable to find component composite from path '"
+ component.getCompositeMetadataFilePath() + "'");
}
setCompositeComponentAttributes(compositeComponent, component);
if (component.getFileResource() == null || component.getFileResource().getProject() == null) {
logger.warn("Unable to load existing '" + compositeComponent.getMetadataFilePath()
+ "' from project - associated component's file resource is null. Assuming new.");
return compositeComponent;
}
IFile compositeComponentFile = compositeComponent.getFileResource(component.getFileResource().getProject());
if (compositeComponentFile == null || !compositeComponentFile.exists()) {
logger.warn("Unable to load '" + compositeComponent.getMetadataFilePath()
+ "' from project - composite component file resource is null");
return compositeComponent;
}
compositeComponent.setFileResource(compositeComponentFile);
try {
compositeComponent.loadFromFile(includeBody);
} catch (Exception e) {
throw new FactoryException(e);
}
if (logger.isDebugEnabled()) {
logger.debug("Loaded " + compositeComponent.getFullDisplayName() + " from file '"
+ compositeComponentFile.getName() + "'");
}
return compositeComponent;
}