Search in sources :

Example 1 with Group

use of com.liferay.portal.model.Group in project liferay-ide by liferay.

the class WebServerServlet method sendGroups.

protected void sendGroups(HttpServletResponse response, User user, String path) throws Exception {
    if (!PropsValues.WEB_SERVER_SERVLET_DIRECTORY_INDEXING_ENABLED) {
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        return;
    }
    List<WebServerEntry> webServerEntries = new ArrayList<WebServerEntry>();
    List<Group> groups = WebDAVUtil.getGroups(user);
    for (Group group : groups) {
        String name = HttpUtil.fixPath(group.getFriendlyURL());
        WebServerEntry webServerEntry = new WebServerEntry(path, name + StringPool.SLASH, null, null, group.getDescription(), 0);
        webServerEntries.add(webServerEntry);
    }
    sendHTML(response, path, webServerEntries);
}
Also used : Group(com.liferay.portal.model.Group) ArrayList(java.util.ArrayList)

Example 2 with Group

use of com.liferay.portal.model.Group in project liferay-ide by liferay.

the class UserLocalServiceImpl method unsetOrganizationUsers.

/**
 * Removes the users from the organization.
 *
 * @param  organizationId the primary key of the organization
 * @param  userIds the primary keys of the users
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public void unsetOrganizationUsers(long organizationId, final long[] userIds) throws PortalException, SystemException {
    Organization organization = organizationPersistence.findByPrimaryKey(organizationId);
    final Group group = organization.getGroup();
    userGroupRoleLocalService.deleteUserGroupRoles(userIds, group.getGroupId());
    organizationPersistence.removeUsers(organizationId, userIds);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userIds);
    PermissionCacheUtil.clearCache();
    Callable<Void> callable = new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            Message message = new Message();
            message.put("groupId", group.getGroupId());
            message.put("userIds", userIds);
            MessageBusUtil.sendMessage(DestinationNames.SUBSCRIPTION_CLEAN_UP, message);
            return null;
        }
    };
    TransactionCommitCallbackRegistryUtil.registerCallback(callable);
}
Also used : Group(com.liferay.portal.model.Group) UserGroup(com.liferay.portal.model.UserGroup) Organization(com.liferay.portal.model.Organization) Indexer(com.liferay.portal.kernel.search.Indexer) MBMessage(com.liferay.portlet.messageboards.model.MBMessage) Message(com.liferay.portal.kernel.messaging.Message) ShardCallable(com.liferay.portal.kernel.dao.shard.ShardCallable) Callable(java.util.concurrent.Callable)

Example 3 with Group

use of com.liferay.portal.model.Group in project liferay-ide by liferay.

the class UserLocalServiceImpl method deleteUser.

/**
 * Deletes the user.
 *
 * @param  user the user
 * @return the deleted user
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public User deleteUser(User user) throws PortalException, SystemException {
    if (!PropsValues.USERS_DELETE) {
        throw new RequiredUserException();
    }
    // Browser tracker
    browserTrackerLocalService.deleteUserBrowserTracker(user.getUserId());
    // Group
    Group group = null;
    if (!user.isDefaultUser()) {
        group = user.getGroup();
    }
    if (group != null) {
        groupLocalService.deleteGroup(group);
    }
    try {
        imageLocalService.deleteImage(user.getPortraitId());
    } catch (NoSuchImageException nsie) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to delete image " + user.getPortraitId());
        }
    }
    // Password policy relation
    passwordPolicyRelLocalService.deletePasswordPolicyRel(User.class.getName(), user.getUserId());
    // Old passwords
    passwordTrackerLocalService.deletePasswordTrackers(user.getUserId());
    // Subscriptions
    subscriptionLocalService.deleteSubscriptions(user.getUserId());
    // External user ids
    userIdMapperLocalService.deleteUserIdMappers(user.getUserId());
    // Announcements
    announcementsDeliveryLocalService.deleteDeliveries(user.getUserId());
    // Asset
    assetEntryLocalService.deleteEntry(User.class.getName(), user.getUserId());
    // Blogs
    blogsStatsUserLocalService.deleteStatsUserByUserId(user.getUserId());
    // Document library
    dlFileRankLocalService.deleteFileRanksByUserId(user.getUserId());
    // Expando
    expandoRowLocalService.deleteRows(user.getUserId());
    // Message boards
    mbBanLocalService.deleteBansByBanUserId(user.getUserId());
    mbStatsUserLocalService.deleteStatsUsersByUserId(user.getUserId());
    mbThreadFlagLocalService.deleteThreadFlagsByUserId(user.getUserId());
    // Membership requests
    membershipRequestLocalService.deleteMembershipRequestsByUserId(user.getUserId());
    // Shopping cart
    shoppingCartLocalService.deleteUserCarts(user.getUserId());
    // Social
    socialActivityLocalService.deleteUserActivities(user.getUserId());
    socialRequestLocalService.deleteReceiverUserRequests(user.getUserId());
    socialRequestLocalService.deleteUserRequests(user.getUserId());
    // Mail
    mailService.deleteUser(user.getCompanyId(), user.getUserId());
    // Contact
    Contact contact = contactLocalService.fetchContact(user.getContactId());
    if (contact != null) {
        contactLocalService.deleteContact(contact);
    }
    // Group roles
    userGroupRoleLocalService.deleteUserGroupRolesByUserId(user.getUserId());
    // Resources
    resourceLocalService.deleteResource(user.getCompanyId(), User.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, user.getUserId());
    // User
    userPersistence.remove(user);
    // Permission cache
    PermissionCacheUtil.clearCache();
    // Workflow
    workflowInstanceLinkLocalService.deleteWorkflowInstanceLinks(user.getCompanyId(), 0, User.class.getName(), user.getUserId());
    return user;
}
Also used : Group(com.liferay.portal.model.Group) UserGroup(com.liferay.portal.model.UserGroup) User(com.liferay.portal.model.User) RequiredUserException(com.liferay.portal.RequiredUserException) NoSuchImageException(com.liferay.portal.NoSuchImageException) Contact(com.liferay.portal.model.Contact)

Example 4 with Group

use of com.liferay.portal.model.Group in project liferay-ide by liferay.

the class UserLocalServiceImpl method sendEmailAddressVerification.

/**
 * Sends an email address verification to the user.
 *
 * @param  user the verification email recipient
 * @param  emailAddress the recipient's email address
 * @param  serviceContext the service context to be applied. Must set the
 *         portal URL, main path, primary key of the layout, remote address,
 *         remote host, and agent for the user.
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public void sendEmailAddressVerification(User user, String emailAddress, ServiceContext serviceContext) throws PortalException, SystemException {
    if (user.isEmailAddressVerified() && StringUtil.equalsIgnoreCase(emailAddress, user.getEmailAddress())) {
        return;
    }
    Ticket ticket = ticketLocalService.addTicket(user.getCompanyId(), User.class.getName(), user.getUserId(), TicketConstants.TYPE_EMAIL_ADDRESS, emailAddress, null, serviceContext);
    String verifyEmailAddressURL = serviceContext.getPortalURL() + serviceContext.getPathMain() + "/portal/verify_email_address?ticketKey=" + ticket.getKey();
    long plid = serviceContext.getPlid();
    if (plid > 0) {
        Layout layout = layoutLocalService.fetchLayout(plid);
        if (layout != null) {
            Group group = layout.getGroup();
            if (!layout.isPrivateLayout() && !group.isUser()) {
                verifyEmailAddressURL += "&p_l_id=" + serviceContext.getPlid();
            }
        }
    }
    String fromName = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String fromAddress = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
    String toName = user.getFullName();
    String toAddress = emailAddress;
    String subject = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_VERIFICATION_SUBJECT);
    String body = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_VERIFICATION_BODY);
    SubscriptionSender subscriptionSender = new SubscriptionSender();
    subscriptionSender.setBody(body);
    subscriptionSender.setCompanyId(user.getCompanyId());
    subscriptionSender.setContextAttributes("[$EMAIL_VERIFICATION_CODE$]", ticket.getKey(), "[$EMAIL_VERIFICATION_URL$]", verifyEmailAddressURL, "[$REMOTE_ADDRESS$]", serviceContext.getRemoteAddr(), "[$REMOTE_HOST$]", serviceContext.getRemoteHost(), "[$USER_ID$]", user.getUserId(), "[$USER_SCREENNAME$]", user.getScreenName());
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setMailId("user", user.getUserId(), System.currentTimeMillis(), PwdGenerator.getPassword());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);
    subscriptionSender.setUserId(user.getUserId());
    subscriptionSender.addRuntimeSubscribers(toAddress, toName);
    subscriptionSender.flushNotificationsAsync();
}
Also used : Ticket(com.liferay.portal.model.Ticket) Group(com.liferay.portal.model.Group) UserGroup(com.liferay.portal.model.UserGroup) User(com.liferay.portal.model.User) Layout(com.liferay.portal.model.Layout) SubscriptionSender(com.liferay.portal.util.SubscriptionSender)

Example 5 with Group

use of com.liferay.portal.model.Group in project liferay-ide by liferay.

the class KBArticleServiceImpl method getGroupKBArticlesRSS.

@Override
public String getGroupKBArticlesRSS(int status, int rssDelta, String rssDisplayStyle, String rssFormat, ThemeDisplay themeDisplay) throws PortalException, SystemException {
    Group group = themeDisplay.getScopeGroup();
    String descriptiveName = HtmlUtil.escape(group.getDescriptiveName(themeDisplay.getLocale()));
    String name = descriptiveName;
    String description = descriptiveName;
    String feedURL = PortalUtil.getLayoutFullURL(themeDisplay);
    List<KBArticle> kbArticles = getGroupKBArticles(group.getGroupId(), status, 0, rssDelta, new KBArticleModifiedDateComparator());
    return exportToRSS(rssDisplayStyle, rssFormat, name, description, feedURL, kbArticles, themeDisplay);
}
Also used : Group(com.liferay.portal.model.Group) KBArticle(com.liferay.knowledgebase.model.KBArticle) KBArticleModifiedDateComparator(com.liferay.knowledgebase.util.comparator.KBArticleModifiedDateComparator)

Aggregations

Group (com.liferay.portal.model.Group)30 User (com.liferay.portal.model.User)15 UserGroup (com.liferay.portal.model.UserGroup)13 ArrayList (java.util.ArrayList)9 UserGroupRole (com.liferay.portal.model.UserGroupRole)6 Role (com.liferay.portal.model.Role)5 Indexer (com.liferay.portal.kernel.search.Indexer)4 Company (com.liferay.portal.model.Company)4 Contact (com.liferay.portal.model.Contact)3 ServiceContext (com.liferay.portal.service.ServiceContext)3 RestfulCollection (org.apache.shindig.protocol.RestfulCollection)3 KBArticle (com.liferay.knowledgebase.model.KBArticle)2 DuplicateUserScreenNameException (com.liferay.portal.DuplicateUserScreenNameException)2 GroupFriendlyURLException (com.liferay.portal.GroupFriendlyURLException)2 NoSuchImageException (com.liferay.portal.NoSuchImageException)2 RequiredUserException (com.liferay.portal.RequiredUserException)2 ReservedUserScreenNameException (com.liferay.portal.ReservedUserScreenNameException)2 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)2 Folder (com.liferay.portal.kernel.repository.model.Folder)2 Organization (com.liferay.portal.model.Organization)2