Search in sources :

Example 1 with VirtualHost

use of com.liferay.portal.kernel.model.VirtualHost in project liferay-imex by jpdacunha.

the class VirtualhostExporter method doExport.

@Override
public void doExport(User user, Properties config, File virtualhostDir, long companyId, Locale locale, List<ExporterRawContent> rawContentToExport, boolean debug) {
    reportService.getStartMessage(_log, "Virtualhost export process");
    boolean enabled = GetterUtil.getBoolean(config.get(ImExVirtualhostExporterPropsKeys.EXPORT_VIRTUALHOST_ENABLED));
    if (enabled) {
        try {
            Company company = companyLocalService.getCompany(companyId);
            List<VirtualHost> hosts = virtualHostCommonService.getCompanyVirtualHost(companyId);
            for (VirtualHost virtualHost : hosts) {
                String hostname = virtualHost.getHostname();
                try {
                    LayoutSet layoutSet = null;
                    Group group = null;
                    boolean publicVirtualHost = true;
                    long layoutSetId = virtualHost.getLayoutSetId();
                    boolean defaultVirtualHost = virtualHost.getDefaultVirtualHost();
                    String groupFriendlyURL = StringPool.BLANK;
                    String languageId = StringPool.BLANK;
                    boolean isCompanyLayoutSet = layoutSetId == VirtualhostCommonService.DEFAULT_LAYOUTSET_ID;
                    if (!isCompanyLayoutSet) {
                        layoutSet = layoutSetLocalService.getLayoutSet(layoutSetId);
                        publicVirtualHost = !layoutSet.isPrivateLayout();
                        group = groupLocalService.getGroup(layoutSet.getGroupId());
                        groupFriendlyURL = group.getFriendlyURL();
                        languageId = virtualHost.getLanguageId();
                    }
                    String companyWebId = company.getWebId();
                    ImexVirtualhost imexVirtualhost = new ImexVirtualhost(companyWebId, groupFriendlyURL, publicVirtualHost, isCompanyLayoutSet, hostname, defaultVirtualHost, languageId);
                    processor.write(imexVirtualhost, virtualhostDir, FileNames.getVirtualhostFileName(virtualHost, company, group, layoutSet, processor.getFileExtension()));
                    reportService.getOK(_log, "Virtualhost : " + hostname + " for group : " + groupFriendlyURL);
                } catch (Exception e) {
                    reportService.getError(_log, "Virtualhost : " + hostname, e);
                    if (debug) {
                        _log.error(e, e);
                    }
                }
            }
        } catch (Exception e) {
            _log.error(e, e);
            reportService.getError(_log, e);
        }
    } else {
        reportService.getDisabled(_log, DESCRIPTION);
    }
    reportService.getEndMessage(_log, "Virtualhost export process");
}
Also used : Group(com.liferay.portal.kernel.model.Group) Company(com.liferay.portal.kernel.model.Company) ImexVirtualhost(com.liferay.imex.virtualhost.model.ImexVirtualhost) VirtualHost(com.liferay.portal.kernel.model.VirtualHost) LayoutSet(com.liferay.portal.kernel.model.LayoutSet)

Example 2 with VirtualHost

use of com.liferay.portal.kernel.model.VirtualHost in project liferay-imex by jpdacunha.

the class VirtualhostCommonServiceImpl method getCompanyVirtualHost.

@Override
public List<VirtualHost> getCompanyVirtualHost(long companyId) {
    ClassLoader classLoader = getClass().getClassLoader();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(VirtualHost.class, classLoader).add(RestrictionsFactoryUtil.eq("companyId", companyId));
    return virtualHostLocalService.dynamicQuery(dynamicQuery);
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) VirtualHost(com.liferay.portal.kernel.model.VirtualHost)

Aggregations

VirtualHost (com.liferay.portal.kernel.model.VirtualHost)2 ImexVirtualhost (com.liferay.imex.virtualhost.model.ImexVirtualhost)1 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)1 Company (com.liferay.portal.kernel.model.Company)1 Group (com.liferay.portal.kernel.model.Group)1 LayoutSet (com.liferay.portal.kernel.model.LayoutSet)1