Search in sources :

Example 11 with Group

use of com.liferay.portal.kernel.model.Group in project liferay-db-setup-core by ableneo.

the class LiferaySetup method setupGroup.

private static void setupGroup(Setup setup, String runAsUserEmail, long companyId, String groupName) throws PortalException {
    Group group = GroupLocalServiceUtil.getGroup(companyId, groupName);
    SetupConfigurationThreadLocal.setRunInGroupId(group.getGroupId());
    setupPortalGroup(setup);
}
Also used : Group(com.liferay.portal.kernel.model.Group)

Example 12 with Group

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

the class ExportRolePermissionsServiceImpl method getResource.

private Resource getResource(long companyId, long roleId, String resource, List<String> actions, boolean allActions) throws PortalException, SystemException {
    Resource r = new Resource();
    r.setResourceName(resource);
    Company company = companyLocalService.getCompany(companyId);
    Role role = roleLocalService.getRole(roleId);
    for (String actionId : actions) {
        Action action = new Action();
        action.setActionId(actionId);
        Scope scope = getScope(company, role, resource, actionId);
        action.setScope(scope);
        if (allActions || !scope.equals(Scope.NONE)) {
            r.getActionList().add(action);
            if (scope.equals(Scope.GROUP)) {
                LinkedHashMap<String, Object> groupParams = new LinkedHashMap<String, Object>();
                @SuppressWarnings("rawtypes") List<Comparable> rolePermissions = new ArrayList<Comparable>();
                rolePermissions.add(resource);
                rolePermissions.add(new Integer(ResourceConstants.SCOPE_GROUP));
                rolePermissions.add(actionId);
                rolePermissions.add(new Long(role.getRoleId()));
                groupParams.put("rolePermissions", rolePermissions);
                List<Group> groups = groupLocalService.search(company.getCompanyId(), null, null, groupParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
                for (Group group : groups) {
                    if (group.isSite()) {
                        action.getSitesNames().add(group.getName());
                    }
                /*else {
								_log.error("Group identified by [" + group.getFriendlyURL() + "] is not a site");
								throw new IllegalStateException();
							}*/
                }
            }
        }
    }
    return r;
}
Also used : Group(com.liferay.portal.kernel.model.Group) Company(com.liferay.portal.kernel.model.Company) Action(com.liferay.imex.role.model.Action) Resource(com.liferay.imex.role.model.Resource) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Role(com.liferay.portal.kernel.model.Role) Scope(com.liferay.imex.role.model.Scope)

Example 13 with Group

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

the class SiteExporter method doExport.

@Override
public void doExport(User user, Properties config, File sitesDir, long companyId, Locale locale, List<ExporterRawContent> rawContentToExport, boolean debug) {
    reportService.getStartMessage(_log, "SITE export process");
    boolean enabled = GetterUtil.getBoolean(config.get(ImExSiteExporterPropsKeys.EXPORT_SITE_ENABLED));
    boolean privatePagesEnabled = GetterUtil.getBoolean(config.get(ImExSiteExporterPropsKeys.EXPORT_SITE_PRIVATE_PAGE_ENABLED));
    boolean publicPagesEnabled = GetterUtil.getBoolean(config.get(ImExSiteExporterPropsKeys.EXPORT_SITE_PUBLIC_PAGE_ENABLED));
    if (enabled) {
        try {
            List<Group> bddGroups = groupLocalService.getCompanyGroups(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
            List<Group> includedGroups = manageSitesExclusions(config, bddGroups);
            List<Group> groups = manageSitesOrder(config, includedGroups);
            for (Group group : groups) {
                boolean isSite = group.isSite() && !group.getFriendlyURL().equals(GroupConstants.CONTROL_PANEL_FRIENDLY_URL);
                if (isSite) {
                    reportService.getStartMessage(_log, group, locale);
                    doExport(companyId, user, config, locale, debug, privatePagesEnabled, publicPagesEnabled, sitesDir, group);
                    reportService.getEndMessage(_log, group, locale);
                } else {
                    String groupName = GroupUtil.getGroupName(group, locale);
                    _log.debug("Skipping [" + groupName + "] because it's not a site.");
                    if (debug) {
                        reportService.getSkipped(_log, groupName);
                    }
                }
            }
        } catch (ImexException e) {
            _log.error(e, e);
            reportService.getError(_log, e);
        } catch (PortalException e) {
            _log.error(e, e);
        }
    } else {
        reportService.getDisabled(_log, DESCRIPTION);
    }
    reportService.getEndMessage(_log, "SITE export process");
}
Also used : Group(com.liferay.portal.kernel.model.Group) ImexException(com.liferay.imex.core.util.exception.ImexException) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 14 with Group

use of com.liferay.portal.kernel.model.Group 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 15 with Group

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

the class WcDDMExporter method doExport.

@Override
public void doExport(User user, Properties config, File wcDdmDir, long companyId, Locale locale, List<ExporterRawContent> rawContentToExport, boolean debug) {
    reportService.getStartMessage(_log, "WEBCONTENT export process");
    boolean enabled = GetterUtil.getBoolean(config.get(ImExWCDDmExporterPropsKeys.EXPORT_WCDDM_ENABLED));
    if (enabled) {
        try {
            List<Group> groups = groupLocalService.getCompanyGroups(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
            for (Group group : groups) {
                boolean isSite = group.isSite() && !group.getFriendlyURL().equals("/control_panel");
                if (isSite) {
                    reportService.getStartMessage(_log, group, locale);
                    doExport(config, group, wcDdmDir, locale, rawContentToExport, debug);
                    reportService.getEndMessage(_log, group, locale);
                }
            }
        } catch (ImexException e) {
            _log.error(e, e);
            reportService.getError(_log, e);
        }
    } else {
        reportService.getDisabled(_log, "WEBCONTENT export");
    }
    reportService.getEndMessage(_log, "WEBCONTENT export process");
}
Also used : Group(com.liferay.portal.kernel.model.Group) ImexException(com.liferay.imex.core.util.exception.ImexException)

Aggregations

Group (com.liferay.portal.kernel.model.Group)34 PortalException (com.liferay.portal.kernel.exception.PortalException)9 UserGroup (com.liferay.portal.kernel.model.UserGroup)6 ArrayList (java.util.ArrayList)6 Company (com.liferay.portal.kernel.model.Company)5 LayoutSet (com.liferay.portal.kernel.model.LayoutSet)4 ServiceContext (com.liferay.portal.kernel.service.ServiceContext)4 ImexException (com.liferay.imex.core.util.exception.ImexException)3 SystemException (com.liferay.portal.kernel.exception.SystemException)3 List (java.util.List)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 PagePortletType (com.ableneo.liferay.portal.setup.domain.PagePortletType)2 Site (com.ableneo.liferay.portal.setup.domain.Site)2 Action (com.liferay.imex.role.model.Action)2 Resource (com.liferay.imex.role.model.Resource)2 ImexVirtualhost (com.liferay.imex.virtualhost.model.ImexVirtualhost)2 Role (com.liferay.portal.kernel.model.Role)2 UnicodeProperties (com.liferay.portal.kernel.util.UnicodeProperties)2 File (java.io.File)2