Search in sources :

Example 1 with NoSuchGroupException

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 ...");
    }
}
Also used : ImexSite(com.liferay.imex.site.model.ImexSite) File(java.io.File) NoSuchGroupException(com.liferay.portal.kernel.exception.NoSuchGroupException) NoSuchGroupException(com.liferay.portal.kernel.exception.NoSuchGroupException) ImexException(com.liferay.imex.core.util.exception.ImexException) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 2 with NoSuchGroupException

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;
}
Also used : Group(com.liferay.portal.kernel.model.Group) HashMap(java.util.HashMap) NoSuchCompanyException(com.liferay.portal.kernel.exception.NoSuchCompanyException) TreeMap(java.util.TreeMap) NoSuchGroupException(com.liferay.portal.kernel.exception.NoSuchGroupException) ImexVirtualhost(com.liferay.imex.virtualhost.model.ImexVirtualhost) ExtendedImexVirtualhost(com.liferay.imex.virtualhost.importer.model.ExtendedImexVirtualhost) ExtendedImexVirtualhost(com.liferay.imex.virtualhost.importer.model.ExtendedImexVirtualhost) File(java.io.File) LayoutSet(com.liferay.portal.kernel.model.LayoutSet)

Aggregations

NoSuchGroupException (com.liferay.portal.kernel.exception.NoSuchGroupException)2 File (java.io.File)2 ImexException (com.liferay.imex.core.util.exception.ImexException)1 ImexSite (com.liferay.imex.site.model.ImexSite)1 ExtendedImexVirtualhost (com.liferay.imex.virtualhost.importer.model.ExtendedImexVirtualhost)1 ImexVirtualhost (com.liferay.imex.virtualhost.model.ImexVirtualhost)1 NoSuchCompanyException (com.liferay.portal.kernel.exception.NoSuchCompanyException)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 Group (com.liferay.portal.kernel.model.Group)1 LayoutSet (com.liferay.portal.kernel.model.LayoutSet)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1