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