use of com.liferay.imex.core.api.configuration.model.ImexProperties in project liferay-imex by jpdacunha.
the class ImexCoreServiceImpl method setFilesPermissions.
private void setFilesPermissions(File destinationDir) throws ImexException {
File[] files = destinationDir.listFiles();
if (files != null && files.length > 0) {
ImexProperties imexProps = new ImexProperties();
configurationService.loadCoreConfiguration(imexProps);
Properties props = imexProps.getProperties();
List<String> readExtensions = CollectionUtil.getList(props.getProperty(ImExCorePropsKeys.DEPLOYER_READ_PERMISSION_FILES_EXTENSIONS));
List<String> writeExtensions = CollectionUtil.getList(props.getProperty(ImExCorePropsKeys.DEPLOYER_WRITE_PERMISSION_FILES_EXTENSIONS));
List<String> executeExtensions = CollectionUtil.getList(props.getProperty(ImExCorePropsKeys.DEPLOYER_EXECUTE_PERMISSION_FILES_EXTENSIONS));
for (File file : files) {
String extension = FileUtil.getExtension(file);
if (Validator.isNotNull(extension)) {
boolean readable = (readExtensions != null && readExtensions.contains(extension));
boolean writable = (writeExtensions != null && writeExtensions.contains(extension));
boolean executable = (executeExtensions != null && executeExtensions.contains(extension));
if (!readable && !writable && !executable) {
// A file is at least readable
readable = true;
}
FileUtil.setFilePermissions(file, writable, readable, executable);
} else {
_log.warn("Unable to set permission for file [" + file.getAbsolutePath() + "] because his extension is undefined.");
}
}
} else {
_log.debug("Directory is empty");
}
}
use of com.liferay.imex.core.api.configuration.model.ImexProperties in project liferay-imex by jpdacunha.
the class ImexConfigurationServiceImpl method loadCoreConfigurationMap.
private Map<String, Properties> loadCoreConfigurationMap() {
Map<String, Properties> bundleConf = new HashMap<>();
ImexProperties props = new ImexProperties();
loadCoreConfiguration(props);
Bundle bundle = FrameworkUtil.getBundle(this.getClass());
bundleConf.put(bundle.getSymbolicName(), props.getProperties());
return bundleConf;
}
use of com.liferay.imex.core.api.configuration.model.ImexProperties in project liferay-imex by jpdacunha.
the class ListProfileCommand method lp.
public void lp() {
ImexProperties config = new ImexProperties();
configurationService.loadCoreConfiguration(config);
Properties configAsProperties = config.getProperties();
String[] supportedProfiles = CollectionUtil.getArray(configAsProperties.getProperty(ImExCorePropsKeys.MANAGES_PROFILES_LIST));
if (supportedProfiles != null && supportedProfiles.length > 0) {
TableBuilder tableBuilder = new TableBuilder();
tableBuilder.addHeaders(COLUMN_NAMES);
for (String profile : Arrays.asList(supportedProfiles)) {
tableBuilder.addRow(profile);
}
tableBuilder.print();
} else {
System.out.println("No supported profiles. Please see [" + ImExCorePropsKeys.MANAGES_PROFILES_LIST + "] paramater to configure profiles.");
}
}
use of com.liferay.imex.core.api.configuration.model.ImexProperties 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