use of com.liferay.imex.rest.trigger.api.comparator.ExporterDescriptorNameComparator in project liferay-imex by jpdacunha.
the class ExportersResourceImpl method getExportersPage.
@Override
public Page<ExporterDescriptor> getExportersPage() throws Exception {
List<ExporterDescriptor> descriptors = new ArrayList<>();
Map<String, ServiceReference<Exporter>> exporters = trackerService.getExporters();
if (exporters != null && exporters.size() > 0) {
for (Map.Entry<String, ServiceReference<Exporter>> entry : exporters.entrySet()) {
ServiceReference<Exporter> serviceReference = entry.getValue();
Bundle bundle = serviceReference.getBundle();
Exporter exporter = bundle.getBundleContext().getService(serviceReference);
String ranking = (Integer) serviceReference.getProperty(OSGIServicePropsKeys.SERVICE_RANKING) + "";
String description = (String) serviceReference.getProperty(OSGIServicePropsKeys.IMEX_COMPONENT_DESCRIPTION);
String priority = (String) serviceReference.getProperty(OSGIServicePropsKeys.IMEX_COMPONENT_EXECUTION_PRIORITY);
String name = bundle.getSymbolicName();
boolean profiled = exporter.isProfiled();
ExporterDescriptor descriptor = new ExporterDescriptor();
descriptor.setDescription(description);
descriptor.setName(name);
descriptor.setPriority(Integer.valueOf(priority));
descriptor.setProfiled(profiled);
descriptor.setRanking(ranking);
ImexProperties config = new ImexProperties();
configurationService.loadCoreConfiguration(config);
Properties configAsProperties = config.getProperties();
String[] supportedProfilesIds = CollectionUtil.getArray(configAsProperties.getProperty(ImExCorePropsKeys.MANAGES_PROFILES_LIST));
descriptor.setSupportedProfilesIds(supportedProfilesIds);
descriptors.add(descriptor);
Collections.sort(descriptors, new ExporterDescriptorNameComparator());
}
} else {
_log.debug("No registered exporters");
}
return Page.of(descriptors);
}
Aggregations