本文整理汇总了Java中com.liferay.portal.service.GroupLocalServiceUtil类的典型用法代码示例。如果您正苦于以下问题:Java GroupLocalServiceUtil类的具体用法?Java GroupLocalServiceUtil怎么用?Java GroupLocalServiceUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GroupLocalServiceUtil类属于com.liferay.portal.service包,在下文中一共展示了GroupLocalServiceUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeToShite
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
public void changeToShite(long workingUnitIdOld,long workingUnitId, User user) throws PortalException, SystemException{
WorkingUnit work = WorkingUnitLocalServiceUtil.getWorkingUnit(workingUnitId);
WorkingUnit workold = WorkingUnitLocalServiceUtil.getWorkingUnit(workingUnitIdOld);
long userId = user.getUserId();
//Group group = GroupLocalServiceUtil.getG(companyId, userId);
List<Group> groups = user.getGroups();
boolean f = false;
for (int i = 0; i < groups.size(); i++){
if (groups.get(i).getGroupId() == workold.getLocalSiteId() ){
f = true;
break;
}
}
if (work.getLocalSiteId() != workold.getLocalSiteId() || !f){
if (workold.getLocalSiteId() != PortletKeys.LONG_DEFAULT && f) {
GroupLocalServiceUtil.deleteUserGroup(userId,
workold.getLocalSiteId());
}
if (work.getLocalSiteId() != PortletKeys.LONG_DEFAULT) {
System.out.println(" changeToShite " + workingUnitId + " " + work.getLocalSiteId() + " " + userId);
GroupLocalServiceUtil.addUserGroup(userId,
work.getLocalSiteId());
System.out.println(" changeToShite " + workingUnitId + " " + work.getLocalSiteId() + " " + userId);
}
}
}
示例2: addStudentToCourse
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
@JSONWebService
public void addStudentToCourse(long courseId,String login) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.fetchCourse(courseId);
User user = userLocalService.fetchUserByScreenName(serviceContext.getCompanyId(), login);
if(course!=null && user!=null){
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
//sendEmail(user,course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
course.getGroupCreatedId(), RoleLocalServiceUtil.getRole(serviceContext.getCompanyId(), RoleConstants.SITE_MEMBER).getRoleId());
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);
}
}
}
示例3: editUserInscriptionDates
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
public void editUserInscriptionDates(long courseId,long userId,Date allowStartDate,Date allowFinishDate) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.getCourse(courseId);
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
User user = userLocalService.getUser(userId);
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
return;
}
CourseResult courseResult=courseResultLocalService.getCourseResultByCourseAndUser(courseId, user.getUserId());
if(courseResult==null)
{
courseResultLocalService.create(courseId, user.getUserId(), allowStartDate, allowFinishDate);
}
else
{
courseResult.setAllowStartDate(allowStartDate);
courseResult.setAllowFinishDate(allowFinishDate);
courseResultLocalService.updateCourseResult(courseResult);
}
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.UPDATE, null);
}
}
示例4: addTeacherToCourse
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
@JSONWebService
public void addTeacherToCourse(long courseId,String login) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.getCourse(courseId);
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
User user = UserLocalServiceUtil.getUserByScreenName(serviceContext.getCompanyId(), login);
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
//sendEmail(user,course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
course.getGroupCreatedId(), LmsPrefsLocalServiceUtil.getLmsPrefs(serviceContext.getCompanyId()).getTeacherRole());
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);
}
}
示例5: addEditorToCourse
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
@JSONWebService
public void addEditorToCourse(long courseId,String login) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.getCourse(courseId);
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
User user = UserLocalServiceUtil.getUserByScreenName(serviceContext.getCompanyId(), login);
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
//sendEmail(user,course);
}
UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
course.getGroupCreatedId(), LmsPrefsLocalServiceUtil.getLmsPrefs(serviceContext.getCompanyId()).getEditorRole());
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);
}
}
示例6: removeStudentFromCourse
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
@JSONWebService
public void removeStudentFromCourse(long courseId,String login) throws PrincipalException, PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.getCourse(courseId);
if(getPermissionChecker().hasPermission(course.getGroupId(), Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
{
User user = UserLocalServiceUtil.getUserByScreenName(serviceContext.getCompanyId(), login);
GroupLocalServiceUtil.unsetUserGroups(user.getUserId(),new long[] { course.getGroupCreatedId() });
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.UNREGISTER, null);
}
}
示例7: myCourses
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
@JSONWebService
public java.util.List<Course> myCourses() throws PortalException, SystemException
{
User usuario= this.getUser();
java.util.List<Group> groups= GroupLocalServiceUtil.getUserGroups(usuario.getUserId());
java.util.List<Course> results=new java.util.ArrayList<Course>();
for(Group groupCourse:groups)
{
Course course=courseLocalService.fetchByGroupCreatedId(groupCourse.getGroupId());
if(course!=null)
{
results.add(course);
}
}
return results;
}
示例8: getUserCourses
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
public List<Course> getUserCourses(long userId) throws PortalException, SystemException
{
User usuario= userLocalService.getUser(userId);
List<Group> groups= GroupLocalServiceUtil.getUserGroups(usuario.getUserId());
List<Course> results=new java.util.ArrayList<Course>();
for(Group groupCourse:groups)
{
Course course=courseLocalService.fetchByGroupCreatedId(groupCourse.getGroupId());
if(course!=null)
{
results.add(course);
}
}
return results;
}
示例9: existsCourseName
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public boolean existsCourseName(Long companyId, Long courseId, String groupName) throws SystemException, PortalException {
DynamicQuery consulta = DynamicQueryFactoryUtil.forClass(Group.class, PortalClassLoaderUtil.getClassLoader());
consulta.add(PropertyFactoryUtil.forName("name").eq(groupName));
consulta.add(PropertyFactoryUtil.forName("companyId").eq(companyId));
if (courseId != null) {
Course course = CourseLocalServiceUtil.getCourse(courseId);
consulta.add(PropertyFactoryUtil.forName("groupId").ne(course.getGroupCreatedId()));
}
List<Group> list = (List<Group>)GroupLocalServiceUtil.dynamicQuery(consulta);
if(!list.isEmpty() && list.size() > 0){
return true;
}
return false;
}
示例10: editUserInscriptionDates
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
public void editUserInscriptionDates(long courseId,long userId,Date allowStartDate,Date allowFinishDate) throws PortalException, SystemException
{
ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
Course course=courseLocalService.getCourse(courseId);
User user = userLocalService.getUser(userId);
if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
return;
}
CourseResult courseResult=courseResultLocalService.getCourseResultByCourseAndUser(courseId, user.getUserId());
if(courseResult==null)
{
courseResultLocalService.create(courseId, user.getUserId(), allowStartDate, allowFinishDate);
}
else
{
courseResult.setAllowStartDate(allowStartDate);
courseResult.setAllowFinishDate(allowFinishDate);
courseResultLocalService.updateCourseResult(courseResult);
}
//auditing
AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.UPDATE, null);
}
示例11: checkgroups
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
@ProcessAction(name="checkgroups")
public void checkgroups(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
List<Course> courses = CourseLocalServiceUtil.findByCompanyId(themeDisplay.getCompanyId());
int counter = 0;
for(Course course: courses){
if(log.isDebugEnabled())log.debug("Course::"+course.getCourseId());
Group group = GroupLocalServiceUtil.getGroup(course.getGroupCreatedId());
ClassName cn = ClassNameLocalServiceUtil.getClassName(Course.class.getName());
if(!group.getClassName().equals(Course.class.getName())){
if(log.isDebugEnabled())log.debug("Change!"+group.getGroupId());
group.setClassNameId(cn.getClassNameId());
group.setClassPK(course.getCourseId());
GroupLocalServiceUtil.updateGroup(group);
counter++;
}
}
actionResponse.setRenderParameter("counter", String.valueOf(counter));
SessionMessages.add(actionRequest, "ok");
}
示例12: getComunidadesDisponiveis
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
/**
* Lista todas as comunidades públicas, privadas e restritas da companhia
*
* @throws SystemException
*/
@SuppressWarnings("unchecked")
public List<Group> getComunidadesDisponiveis(final long companyId) throws SystemException {
final long groupClassNameId = ClassNameLocalServiceUtil.getClassNameId(Group.class);
final DynamicQuery query = DynamicQueryFactoryUtil.forClass(Group.class, PortalClassLoaderUtil.getClassLoader());
query.add(RestrictionsFactoryUtil.eq("companyId", companyId));
query.add(RestrictionsFactoryUtil.eq("classNameId", groupClassNameId));
query.add(RestrictionsFactoryUtil.in("type", new Object[] { GroupConstants.TYPE_SITE_OPEN, GroupConstants.TYPE_SITE_PRIVATE,
GroupConstants.TYPE_SITE_RESTRICTED }));
query.add(RestrictionsFactoryUtil.eq("parentGroupId", GroupConstants.DEFAULT_PARENT_GROUP_ID));
query.add(RestrictionsFactoryUtil.eq("active", true));
query.add(RestrictionsFactoryUtil.ne("name", GroupConstants.CONTROL_PANEL));
query.addOrder(OrderFactoryUtil.asc("name"));
return (List<Group>) GroupLocalServiceUtil.dynamicQuery(query);
}
示例13: assinaturasThreadForum
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
/**
* @param userId
* @throws SystemException
*/
private void assinaturasThreadForum(long userId) throws SystemException {
List<Subscription> subscricoes;
// Threads de forum
subscricoes = SubscriptionLocalServiceUtil.getUserSubscriptions(userId,
MBThread.class.getName());
for (Subscription subscricao : subscricoes) {
try {
MBThread thread = MBThreadLocalServiceUtil
.getMBThread(subscricao.getClassPK());
MBMessage mensagemRaiz = MBMessageLocalServiceUtil
.getMBMessage(thread.getRootMessageId());
if (mensagemRaiz.getClassPK() != 0)
continue;
Group grupo = GroupLocalServiceUtil.getGroup(thread
.getGroupId());
adicionaAssinatura(assinaturas, subscricao,
TipoAssinatura.FORUM_THREAD, grupo,
mensagemRaiz.getSubject());
} catch (PortalException e) {
// TODO log
}
}
}
示例14: assinaturasNoWiki
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
/**
* @param userId
* @throws SystemException
*/
private void assinaturasNoWiki(long userId) throws SystemException {
List<Subscription> subscricoes;
// Nós de wiki
subscricoes = SubscriptionLocalServiceUtil.getUserSubscriptions(userId,
WikiNode.class.getName());
for (Subscription subscricao : subscricoes) {
try {
WikiNode noWiki = WikiNodeLocalServiceUtil
.getWikiNode(subscricao.getClassPK());
Group grupo = GroupLocalServiceUtil.getGroup(noWiki
.getGroupId());
adicionaAssinatura(assinaturas, subscricao,
TipoAssinatura.WIKI_NODE, grupo,
noWiki.getDescription());
} catch (PortalException e) {
// TODO log
}
}
}
示例15: assinaturasPaginaWiki
import com.liferay.portal.service.GroupLocalServiceUtil; //导入依赖的package包/类
/**
* @param userId
* @throws SystemException
*/
private void assinaturasPaginaWiki(long userId) throws SystemException {
List<Subscription> subscricoes;
// Páginas wiki
subscricoes = SubscriptionLocalServiceUtil.getUserSubscriptions(userId,
WikiPage.class.getName());
for (Subscription subscricao : subscricoes) {
try {
WikiPage paginaWiki = WikiPageLocalServiceUtil
.getWikiPage(subscricao.getClassPK());
Group grupo = GroupLocalServiceUtil.getGroup(paginaWiki
.getGroupId());
adicionaAssinatura(assinaturas, subscricao,
TipoAssinatura.WIKI_PAGE, grupo, paginaWiki.getTitle());
} catch (PortalException e) {
// TODO log
}
}
}