use of org.entando.entando.aps.system.init.model.Component in project entando-core by entando.
the class ComponentManager method getOrderedComponents.
private List<Component> getOrderedComponents(List<Component> components) {
List<Component> ordered = new ArrayList<Component>();
for (int i = 0; i < components.size(); i++) {
Component component = components.get(i);
boolean added = false;
for (int j = 0; j < ordered.size(); j++) {
Component current = ordered.get(j);
if (null != current.getDependencies() && current.getDependencies().contains(component.getCode())) {
ordered.add(j, component);
added = true;
break;
}
}
if (!added) {
ordered.add(component);
}
}
return ordered;
}
use of org.entando.entando.aps.system.init.model.Component in project entando-core by entando.
the class ComponentManager method loadComponents.
protected void loadComponents() throws ApsSystemException {
try {
ComponentLoader loader = new ComponentLoader(this.getLocationPatterns(), this.getPostProcessClasses());
Map<String, Component> componentMap = loader.getComponents();
List<Component> components = new ArrayList<Component>();
components.addAll(componentMap.values());
List<Component> orderedComponents = this.getOrderedComponents(components);
this.setComponents(orderedComponents);
} catch (Throwable t) {
_logger.error("Error loading components definitions", t);
throw new ApsSystemException("Error loading components definitions", t);
}
}
use of org.entando.entando.aps.system.init.model.Component in project entando-core by entando.
the class ComponentDefDOM method getComponent.
protected Component getComponent(Map<String, String> postProcessClasses) {
Component component = null;
try {
Element rootElement = this._doc.getRootElement();
component = new Component(rootElement, postProcessClasses);
} catch (Throwable t) {
_logger.error("Error loading component", t);
}
return component;
}
use of org.entando.entando.aps.system.init.model.Component in project entando-core by entando.
the class ComponentLoader method loadComponent.
private void loadComponent(String locationPattern, Map<String, String> postProcessClasses) throws Throwable {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources(locationPattern);
ComponentDefDOM dom = null;
Set<String> codes = new HashSet<String>();
for (int i = 0; i < resources.length; i++) {
Resource resource = resources[i];
InputStream is = null;
String path = resource.getURL().getPath();
try {
is = resource.getInputStream();
String xml = FileTextReader.getText(is);
dom = new ComponentDefDOM(xml, path);
Component component = dom.getComponent(postProcessClasses);
if (null != component) {
if (codes.add(component.getCode())) {
_logger.debug("Component '{}' loaded", component.getCode());
this.getComponents().put(component.getCode(), component);
} else {
_logger.debug("Component '{}' already loaded", component.getCode());
}
}
} catch (Throwable t) {
_logger.error("Error loading Component definition by location Pattern '{}'", path, t);
} finally {
if (null != is) {
is.close();
}
}
}
}
use of org.entando.entando.aps.system.init.model.Component in project entando-core by entando.
the class DatabaseAction method checkRestore.
public boolean checkRestore(List<Component> currentComponents, DataSourceDumpReport report) {
List<String> codes = new ArrayList<String>();
codes.add("entandoCore");
for (int i = 0; i < currentComponents.size(); i++) {
Component component = currentComponents.get(i);
codes.add(component.getCode());
}
List<ComponentInstallationReport> reports = report.getComponentsHistory();
if (reports.size() != codes.size()) {
return false;
}
for (int i = 0; i < reports.size(); i++) {
ComponentInstallationReport componentReport = reports.get(i);
if (!codes.contains(componentReport.getComponentCode())) {
return false;
}
}
return true;
}
Aggregations