Search in sources :

Example 16 with Group

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

the class SiteImporter method doUpdateSitesHierarchy.

private void doUpdateSitesHierarchy(long companyId, Map<String, String> toUpdateParentGroups, boolean debug) {
    reportService.getStartMessage(_log, "Managing sites hierarchy");
    if (toUpdateParentGroups.size() == 0) {
        reportService.getMessage(_log, "no hierarchy to manage");
    } else {
        for (Entry<String, String> entry : toUpdateParentGroups.entrySet()) {
            String friendlyURL = null;
            try {
                friendlyURL = entry.getKey();
                String parentGroupIdFriendlyUrl = entry.getValue();
                Group group = groupLocalService.getFriendlyURLGroup(companyId, friendlyURL);
                siteCommonService.attachToParentSite(group, parentGroupIdFriendlyUrl);
            } catch (Exception e) {
                reportService.getError(_log, friendlyURL, e);
                if (debug) {
                    _log.error(e, e);
                }
            }
        }
    }
    reportService.getEndMessage(_log, "Managing sites hierarchy");
}
Also used : Group(com.liferay.portal.kernel.model.Group) LARFileNameException(com.liferay.exportimport.kernel.exception.LARFileNameException) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 17 with Group

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

the class SiteImporter method updateLiferayGroup.

private Group updateLiferayGroup(UnicodeProperties typeSettingsProperties, ServiceContext serviceContext, Map<Locale, String> nameMap, Map<Locale, String> descriptionMap, int type, String friendlyURL, boolean active, int membershipRestriction, boolean manualMembership, boolean inheritContent, long defaultParentGroupId, Group group) throws PortalException {
    long groupId = group.getGroupId();
    Group updatedGroup = groupLocalService.updateGroup(groupId, defaultParentGroupId, nameMap, descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, inheritContent, active, serviceContext);
    updatedGroup = groupLocalService.updateGroup(groupId, typeSettingsProperties.toString());
    return updatedGroup;
}
Also used : Group(com.liferay.portal.kernel.model.Group)

Example 18 with Group

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

the class SiteCommonServiceImpl method eraseSiteHierarchy.

@Override
@Transactional
public void eraseSiteHierarchy(Group group) throws PortalException {
    ClassLoader classLoader = getClass().getClassLoader();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Group.class, classLoader).add(RestrictionsFactoryUtil.eq("parentGroupId", group.getGroupId())).setProjection(ProjectionFactoryUtil.property("groupId"));
    List<Long> siteChilds = groupLocalService.dynamicQuery(dynamicQuery);
    for (long childGroupId : siteChilds) {
        Group childGroup = groupLocalService.getGroup(childGroupId);
        this.detachGroupFromParent(childGroup);
        reportService.getMessage(_log, "Detached [" + childGroup.getFriendlyURL() + "] from [" + group.getFriendlyURL() + "] ...");
    }
}
Also used : Group(com.liferay.portal.kernel.model.Group) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) Transactional(com.liferay.portal.kernel.transaction.Transactional)

Example 19 with Group

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

the class AdtExporter method doExport.

@Override
public void doExport(User user, Properties config, File adtDir, long companyId, Locale locale, List<ExporterRawContent> rawContentToExport, boolean debug) {
    reportService.getStartMessage(_log, "ADT export process");
    boolean enabled = GetterUtil.getBoolean(config.get(ImExWCDDmExporterPropsKeys.EXPORT_ADT_ENABLED));
    if (enabled) {
        String stringList = GetterUtil.getString(config.get(ImExWCDDmExporterPropsKeys.EXPORT_ADT_TYPES_LIST));
        List<String> types = CollectionUtil.getList(stringList);
        if (types != null && types.size() > 0) {
            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);
                        for (String classType : types) {
                            doExport(config, group, adtDir, locale, debug, classType, rawContentToExport);
                        }
                        reportService.getEndMessage(_log, group, locale);
                    } else {
                        reportService.getSkipped(_log, "group : " + GroupUtil.getGroupName(group, locale));
                    }
                }
            } catch (ImexException e) {
                _log.error(e, e);
                reportService.getError(_log, e);
            }
        } else {
            reportService.getMessage(_log, "No configured types to export");
        }
    } else {
        reportService.getDisabled(_log, DESCRIPTION);
    }
    reportService.getEndMessage(_log, "ADT export process");
}
Also used : Group(com.liferay.portal.kernel.model.Group) ImexException(com.liferay.imex.core.util.exception.ImexException)

Example 20 with Group

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

the class SiteCommonServiceImpl method getSiteParentGroupId.

@Override
public long getSiteParentGroupId(long companyId, String parentGroupIdFriendlyUrl) throws PortalException {
    long parentGroupId = GroupConstants.DEFAULT_PARENT_GROUP_ID;
    Group parentGroup = this.getSiteByFriendlyURL(companyId, parentGroupIdFriendlyUrl);
    if (parentGroup != null) {
        parentGroupId = parentGroup.getGroupId();
    }
    return parentGroupId;
}
Also used : Group(com.liferay.portal.kernel.model.Group)

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