Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_INACTIVE

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_INACTIVE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_INACTIVE.

Prototype

int STATUS_INACTIVE

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_INACTIVE.

Click Source Link

Usage

From source file:at.meduni.liferay.portlet.bbmrieric.model.D2BiobankClp.java

License:Open Source License

@Override
public boolean isInactive() {
    if (getStatus() == WorkflowConstants.STATUS_INACTIVE) {
        return true;
    } else {/*from   w  w w  .  j  ava  2s . c om*/
        return false;
    }
}

From source file:com.liferay.faces.demos.bean.UsersModelBean.java

License:Open Source License

public List<SelectItem> getStatusSelectItems() {

    if (statusSelectItems == null) {
        LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
        statusSelectItems = new ArrayList<SelectItem>();
        statusSelectItems.add(/*from  w  w  w  . j  a v  a  2  s. com*/
                new SelectItem(WorkflowConstants.STATUS_ANY, liferayFacesContext.getMessage("any-status")));
        statusSelectItems.add(
                new SelectItem(WorkflowConstants.STATUS_APPROVED, liferayFacesContext.getMessage("active")));
        statusSelectItems.add(
                new SelectItem(WorkflowConstants.STATUS_INACTIVE, liferayFacesContext.getMessage("inactive")));
    }

    return statusSelectItems;
}

From source file:com.liferay.lms.model.CompetenceClp.java

License:Open Source License

public boolean isInactive() {
    if (getStatus() == WorkflowConstants.STATUS_INACTIVE) {
        return true;
    } else {//  ww w .  j a  v  a  2  s  .c  om
        return false;
    }
}

From source file:com.liferay.portlet.usersadmin.action.EditUserAction.java

License:Open Source License

protected void deleteUsers(ActionRequest actionRequest) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    long[] deleteUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteUserIds"), 0L);

    for (int i = 0; i < deleteUserIds.length; i++) {
        if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {

            int status = WorkflowConstants.STATUS_APPROVED;

            if (cmd.equals(Constants.DEACTIVATE)) {
                status = WorkflowConstants.STATUS_INACTIVE;
            }/*from  w  w w.  ja v a  2  s  .c  om*/

            UserServiceUtil.updateStatus(deleteUserIds[i], status);
        } else {
            UserServiceUtil.deleteUser(deleteUserIds[i]);
        }
    }
}

From source file:com.liferay.privatemessaging.util.PrivateMessagingUtil.java

License:Open Source License

public static List<User> getThreadUsers(long userId, long mbThreadId) throws PortalException {

    List<User> users = new ArrayList<User>();

    // Users who have contributed to the thread

    List<MBMessage> mbMessages = UserThreadServiceUtil.getThreadMessages(mbThreadId, QueryUtil.ALL_POS,
            QueryUtil.ALL_POS, false);//from   www .  java  2 s  .  c  o  m

    for (MBMessage mbMessage : mbMessages) {
        if (userId == mbMessage.getUserId()) {
            continue;
        }

        User user = UserLocalServiceUtil.fetchUser(mbMessage.getUserId());

        if (user == null) {
            user = UserLocalServiceUtil.createUser(mbMessage.getUserId());

            user.setFirstName(mbMessage.getUserName());
            user.setStatus(WorkflowConstants.STATUS_INACTIVE);
        }

        if (!users.contains(user)) {
            users.add(user);
        }
    }

    // Users who can view the thread

    List<UserThread> userThreads = UserThreadLocalServiceUtil.getMBThreadUserThreads(mbThreadId);

    for (UserThread userThread : userThreads) {
        if (userId == userThread.getUserId()) {
            continue;
        }

        User user = UserLocalServiceUtil.fetchUser(userThread.getUserId());

        if (user == null) {
            user = UserLocalServiceUtil.createUser(userThread.getUserId());

            user.setFirstName(userThread.getUserName());
            user.setStatus(WorkflowConstants.STATUS_INACTIVE);
        }

        if (!users.contains(user)) {
            users.add(user);
        }
    }

    return users;
}

From source file:com.liferay.users.admin.web.internal.portlet.action.EditUserMVCActionCommand.java

License:Open Source License

protected void deleteUsers(ActionRequest actionRequest) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    long[] deleteUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteUserIds"), 0L);

    for (long deleteUserId : deleteUserIds) {
        if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {

            int status = WorkflowConstants.STATUS_APPROVED;

            if (cmd.equals(Constants.DEACTIVATE)) {
                status = WorkflowConstants.STATUS_INACTIVE;
            }//w  w w  . j  a va2s .c om

            _userService.updateStatus(deleteUserId, status, new ServiceContext());
        } else {
            _userService.deleteUser(deleteUserId);
        }
    }
}

From source file:com.siemens.sw360.portal.users.UserPortletUtils.java

License:Open Source License

private static User addLiferayUser(PortletRequest request, String firstName, String lastName,
        String emailAddress, long organizationId, long roleId, boolean isMale, String externalId,
        String password, boolean passwordEncrypted, boolean activateImmediately) {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    String screenName = firstName + lastName;
    long companyId = themeDisplay.getCompanyId();

    try {//from   w  w w  . j  a  va  2  s .  c  om
        if (userAlreadyExists(request, emailAddress, externalId, screenName, companyId)) {
            return null;
        }
    } catch (PortalException | SystemException e) {
        log.error(e);
        // won't try to create user if even checking for existing user failed
        return null;
    }

    try {
        ServiceContext serviceContext = ServiceContextFactory.getInstance(request);
        long[] roleIds = roleId == 0 ? new long[] {} : new long[] { roleId };
        long[] organizationIds = organizationId == 0 ? new long[] {} : new long[] { organizationId };
        long[] userGroupIds = null;
        long currentUserId = themeDisplay.getUserId();
        User user = UserLocalServiceUtil.addUser(currentUserId/*creator*/, companyId, false, /*autoPassword*/
                password, password, false, /*autoScreenName*/
                screenName, emailAddress, 0/*facebookId*/, externalId/*openId*/, themeDisplay.getLocale(),
                firstName, ""/*middleName*/, lastName, 0/*prefixId*/, 0/*suffixId*/, isMale, 4/*birthdayMonth*/,
                12/*birthdayDay*/, 1959/*birthdayYear*/, ""/*jobTitle*/, null/*groupIds*/, organizationIds,
                roleIds, userGroupIds, false/*sendEmail*/, serviceContext);
        user.setPasswordReset(false);

        if (passwordEncrypted) {
            user.setPassword(password);
            user.setPasswordEncrypted(true);
        }

        Role role = RoleLocalServiceUtil.getRole(roleId);
        RoleUtil.addUser(role.getRoleId(), user.getUserId());
        UserLocalServiceUtil.updateUser(user);
        RoleLocalServiceUtil.updateRole(role);

        UserLocalServiceUtil.updateStatus(user.getUserId(),
                activateImmediately ? WorkflowConstants.STATUS_APPROVED : WorkflowConstants.STATUS_INACTIVE);
        Indexer indexer = IndexerRegistryUtil.getIndexer(User.class);
        indexer.reindex(user);
        return user;
    } catch (PortalException | SystemException e) {
        log.error(e);
        return null;
    }
}

From source file:it.dontesta.liferay.messagebus.example.mvc.SendEmail.java

License:Open Source License

/**
 * // w w w  . j  a va 2  s . com
 * @param user
 * @return
 * @throws SystemException
 */
@SuppressWarnings("unchecked")
protected List<User> getInactiveUsers(User user) throws SystemException {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(User.class);
    dynamicQuery.add(PropertyFactoryUtil.forName("status").eq(WorkflowConstants.STATUS_INACTIVE));
    dynamicQuery.add(PropertyFactoryUtil.forName("companyId").eq(user.getCompanyId()));

    List<User> userList = UserLocalServiceUtil.dynamicQuery(dynamicQuery);
    return userList;
}

From source file:it.its.ct.gestionaleOP.op.RegistraAssociatoPortlet.java

public void toggleAssociato(ActionRequest areq, ActionResponse ares) {

    try {//w  w w  .  j av  a2s  .co m
        Associato associato = AssociatoLocalServiceUtil.getAssociato(ParamUtil.getLong(areq, "id"));
        associato.setAttivo(!associato.getAttivo());
        AssociatoLocalServiceUtil.updateAssociato(associato);
        if (associato.getAttivo()) {
            UserLocalServiceUtil.updateStatus(associato.getIdLiferay(), WorkflowConstants.STATUS_APPROVED,
                    new ServiceContext());
        } else {
            UserLocalServiceUtil.updateStatus(associato.getIdLiferay(), WorkflowConstants.STATUS_INACTIVE,
                    new ServiceContext());
        }
    } catch (PortalException ex) {
        _log.error(ex.getMessage());
    } catch (SystemException ex) {
        _log.error(ex.getMessage());
    }
}

From source file:org.eclipse.sw360.portal.users.UserPortletUtils.java

License:Open Source License

private static User addLiferayUser(RequestAdapter requestAdapter, String firstName, String lastName,
        String emailAddress, String organizationName, String roleName, boolean male, String externalId,
        String password, boolean passwordEncrypted, boolean activateImmediately)
        throws SystemException, PortalException {
    long companyId = requestAdapter.getCompanyId();

    long organizationId = OrganizationLocalServiceUtil.getOrganizationId(companyId, organizationName);
    final Role role = RoleLocalServiceUtil.getRole(companyId, roleName);
    long roleId = role.getRoleId();

    try {//w w w  . j  a  va2  s.  co  m
        if (userAlreadyExists(requestAdapter.getErrorMessagesConsumer(), emailAddress, externalId, externalId,
                companyId)) {
            return null;
        }
    } catch (PortalException | SystemException e) {
        log.error(e);
        // won't try to create user if even checking for existing user failed
        return null;
    }

    try {
        long[] roleIds = roleId == 0 ? new long[] {} : new long[] { roleId };
        long[] organizationIds = organizationId == 0 ? new long[] {} : new long[] { organizationId };
        long[] userGroupIds = null;
        Optional<ServiceContext> serviceContextOpt = requestAdapter.getServiceContext();
        final ServiceContext serviceContext;
        if (!serviceContextOpt.isPresent()) {
            return null;
        } else {
            serviceContext = serviceContextOpt.get();
        }
        User defaultUser = UserLocalServiceUtil.loadGetDefaultUser(companyId);
        User user = UserLocalServiceUtil.addUser(defaultUser.getUserId()/*creator*/, companyId,
                false, /*autoPassword*/
                password, password, false, /*autoScreenName*/
                externalId, emailAddress, 0/*facebookId*/, externalId/*openId*/, defaultUser.getLocale(),
                firstName, ""/*middleName*/, lastName, 0/*prefixId*/, 0/*suffixId*/, male, 4/*birthdayMonth*/,
                12/*birthdayDay*/, 1959/*birthdayYear*/, ""/*jobTitle*/, null/*groupIds*/, organizationIds,
                roleIds, userGroupIds, false/*sendEmail*/, serviceContext);
        user.setPasswordReset(false);

        if (passwordEncrypted) {
            user.setPassword(password);
            user.setPasswordEncrypted(true);
        }

        RoleUtil.addUser(role.getRoleId(), user.getUserId());
        UserLocalServiceUtil.updateUser(user);
        RoleLocalServiceUtil.updateRole(role);

        UserLocalServiceUtil.updateStatus(user.getUserId(),
                activateImmediately ? WorkflowConstants.STATUS_APPROVED : WorkflowConstants.STATUS_INACTIVE,
                serviceContext);
        Indexer indexer = IndexerRegistryUtil.getIndexer(User.class);
        indexer.reindex(user);
        return user;
    } catch (PortalException | SystemException e) {
        log.error(e);
        return null;
    }
}