use of com.liferay.portal.kernel.exception.NoSuchGroupException in project liferay-imex by jpdacunha.
the class SiteExporter method doExport.
private void doExport(long companyId, User user, Properties config, Locale locale, boolean debug, boolean privatePagesEnabled, boolean publicPagesEnabled, File sitesDir, Group group) throws PortalException, ImexException {
File siteDir = initializeSingleSiteExportDirectory(sitesDir, group, locale);
if (siteDir != null) {
if (siteDir.exists()) {
boolean privateLayout;
String groupName = GroupUtil.getGroupName(group, locale);
String parentGroupIdFriendlyUrl = null;
try {
parentGroupIdFriendlyUrl = siteCommonService.getParentSiteFriendlyURL(companyId, group.getParentGroupId());
processor.write(new ImexSite(group, parentGroupIdFriendlyUrl), siteDir, FileNames.getSiteFileName(group, processor.getFileExtension()));
} catch (NoSuchGroupException e1) {
reportService.getError(_log, groupName, "Site identified by [" + parentGroupIdFriendlyUrl + "] is a parent site an it does not exists. Maybe you can use [" + ImExSiteExporterPropsKeys.EXPORT_SITE_ORDER_FRIENDLYURL_LIST + "] to configure IMEX to import the parent site prior to child site.");
if (debug) {
_log.error(e1, e1);
}
} catch (Exception e) {
reportService.getError(_log, groupName, e);
if (debug) {
_log.error(e, e);
}
}
if (publicPagesEnabled) {
privateLayout = false;
doExportLar(user, config, group, siteDir, locale, privateLayout, debug);
}
if (privatePagesEnabled) {
privateLayout = true;
doExportLar(user, config, group, siteDir, locale, privateLayout, debug);
}
reportService.getOK(_log, groupName, "SITE : " + groupName);
} else {
reportService.getDNE(_log, siteDir.getAbsolutePath());
}
} else {
_log.error("siteDir is null ...");
}
}
use of com.liferay.portal.kernel.exception.NoSuchGroupException in project liferay-imex by jpdacunha.
the class VirtualhostImporter method converToUpdatableMap.
private Map<Long, TreeMap<String, String>> converToUpdatableMap(long companyId, List<ExtendedImexVirtualhost> virtualHosts) throws PortalException {
// Constructing structured map to update
Map<Long, TreeMap<String, String>> layoutSetHostnames = new HashMap<Long, TreeMap<String, String>>();
for (ExtendedImexVirtualhost extendedVirtualHostObj : virtualHosts) {
ImexVirtualhost virtualHostObj = extendedVirtualHostObj.getVirtualhost();
String companyWebId = virtualHostObj.getCompanyWebId();
String groupFriendlyURL = virtualHostObj.getGroupFriendlyURL();
boolean isPublicVirtualHost = virtualHostObj.isPublicVirtualHost();
long layoutSetId = VirtualhostCommonService.DEFAULT_LAYOUTSET_ID;
boolean isCompanyVirtualHost = virtualHostObj.isCompanyVirtualHost();
File virtualHostFile = extendedVirtualHostObj.getSourceFile();
String originFileName = virtualHostFile.getName();
String languageId = virtualHostObj.getLanguageId();
try {
// Verify if company exists
companyLocalService.getCompanyByWebId(companyWebId);
if (!isCompanyVirtualHost) {
// Verify if group exists
Group group = groupLocalService.getFriendlyURLGroup(companyId, groupFriendlyURL);
LayoutSet layoutSet = layoutSetLocalService.getLayoutSet(group.getGroupId(), !isPublicVirtualHost);
layoutSetId = layoutSet.getLayoutSetId();
}
String hostname = virtualHostObj.getHostname();
TreeMap<String, String> currentLayoutSetHostnames = null;
if (Validator.isNotNull(hostname)) {
TreeMap<String, String> treeMap = layoutSetHostnames.get(layoutSetId);
if (treeMap == null) {
layoutSetHostnames.put(layoutSetId, new TreeMap<String, String>());
} else {
_log.debug("Updating existing TreeMap");
}
currentLayoutSetHostnames = layoutSetHostnames.get(layoutSetId);
if (!currentLayoutSetHostnames.containsKey(hostname)) {
currentLayoutSetHostnames.put(hostname, languageId);
} else {
_log.debug("Current TreeMap already contains [" + hostname + "]");
}
} else {
reportService.getError(_log, originFileName, "missing required information hostname");
}
} catch (NoSuchCompanyException e) {
reportService.getDNE(_log, "company identified by [" + companyWebId + "]");
reportService.getSkipped(_log, originFileName);
} catch (NoSuchGroupException e) {
reportService.getDNE(_log, "group identified by [" + groupFriendlyURL + "]");
reportService.getSkipped(_log, originFileName);
}
}
return layoutSetHostnames;
}
Aggregations