Search in sources :

Example 11 with ImexProperties

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");
    }
}
Also used : ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Properties(java.util.Properties) OrderedProperties(com.liferay.imex.core.api.configuration.model.OrderedProperties) File(java.io.File)

Example 12 with ImexProperties

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;
}
Also used : HashMap(java.util.HashMap) Bundle(org.osgi.framework.Bundle) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Properties(java.util.Properties)

Example 13 with ImexProperties

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.");
    }
}
Also used : ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Properties(java.util.Properties) TableBuilder(com.liferay.imex.shell.client.util.TableBuilder)

Example 14 with ImexProperties

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);
}
Also used : Bundle(org.osgi.framework.Bundle) ExporterDescriptorNameComparator(com.liferay.imex.rest.trigger.api.comparator.ExporterDescriptorNameComparator) ArrayList(java.util.ArrayList) Exporter(com.liferay.imex.core.api.exporter.Exporter) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Properties(java.util.Properties) ServiceReference(org.osgi.framework.ServiceReference) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) ExporterDescriptor(com.liferay.imex.rest.trigger.api.dto.v1_0.ExporterDescriptor) Map(java.util.Map)

Aggregations

ImexProperties (com.liferay.imex.core.api.configuration.model.ImexProperties)14 Properties (java.util.Properties)11 ServiceReference (org.osgi.framework.ServiceReference)8 Bundle (org.osgi.framework.Bundle)7 File (java.io.File)6 Map (java.util.Map)6 ProcessIdentifierGenerator (com.liferay.imex.core.api.identifier.ProcessIdentifierGenerator)4 ImexException (com.liferay.imex.core.util.exception.ImexException)4 PortalException (com.liferay.portal.kernel.exception.PortalException)4 Company (com.liferay.portal.kernel.model.Company)4 Exporter (com.liferay.imex.core.api.exporter.Exporter)3 Importer (com.liferay.imex.core.api.importer.Importer)3 OrderedProperties (com.liferay.imex.core.api.configuration.model.OrderedProperties)2 ExporterProcessIdentifierGenerator (com.liferay.imex.core.service.exporter.model.ExporterProcessIdentifierGenerator)2 User (com.liferay.portal.kernel.model.User)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ExporterRawContent (com.liferay.imex.core.api.exporter.model.ExporterRawContent)1 Trigger (com.liferay.imex.core.api.trigger.Trigger)1