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");
}
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);
}
Aggregations