use of com.liferay.imex.rest.trigger.api.dto.v1_0.ImporterDescriptor in project liferay-imex by jpdacunha.
the class ImportersResourceImpl method getImportersPage.
@Override
public Page<ImporterDescriptor> getImportersPage() throws Exception {
List<ImporterDescriptor> descriptors = new ArrayList<>();
Map<String, ServiceReference<Importer>> importers = trackerService.getImporters();
if (importers != null && importers.size() > 0) {
for (Map.Entry<String, ServiceReference<Importer>> entry : importers.entrySet()) {
ServiceReference<Importer> serviceReference = entry.getValue();
Bundle bundle = serviceReference.getBundle();
Importer importer = 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 = importer.isProfiled();
ImporterDescriptor descriptor = new ImporterDescriptor();
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();
if (profiled) {
String[] supportedProfilesIds = CollectionUtil.getArray(configAsProperties.getProperty(ImExCorePropsKeys.MANAGES_PROFILES_LIST));
descriptor.setSupportedProfilesIds(supportedProfilesIds);
}
descriptors.add(descriptor);
Collections.sort(descriptors, new ImporterDescriptorNameComparator());
}
} else {
_log.debug("No registered importers");
}
return Page.of(descriptors);
}
Aggregations