Search in sources :

Example 31 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project liferay-blade-samples by liferay.

the class LogAuthFailure method onFailureByEmailAddress.

@Override
public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {
    try {
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);
        int failures = user.getFailedLoginAttempts();
        _log.log(LogService.LOG_INFO, "onFailureByEmailAddress: " + emailAddress + " has failed to login " + failures + " times");
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 32 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project liferay-blade-samples by liferay.

the class LogMaxFailures method onFailureByEmailAddress.

@Override
public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {
    try {
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);
        boolean lockout = user.isLockout();
        _log.log(LogService.LOG_INFO, "onFailureByEmailAddress: " + emailAddress + " is " + (lockout ? "" : "not") + " locked out.");
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 33 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project liferay-blade-samples by liferay.

the class LogMaxFailures method onFailureByUserId.

@Override
public void onFailureByUserId(long companyId, long userId, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {
    try {
        User user = UserLocalServiceUtil.getUserById(userId);
        boolean lockout = user.isLockout();
        _log.log(LogService.LOG_INFO, "onFailureById: userId " + userId + " is " + (lockout ? "" : "not") + " locked out.");
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 34 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project liferay-blade-samples by liferay.

the class BladeActionConfigurationIcon method _retrieveFile.

private FileEntry _retrieveFile(HttpServletRequest request) {
    try {
        long fileEntryId = ParamUtil.getLong(request, "fileEntryId");
        FileEntry fileEntry = null;
        if (fileEntryId > 0) {
            fileEntry = _dlAppService.getFileEntry(fileEntryId);
        }
        if (fileEntry == null) {
            return null;
        }
        String cmd = ParamUtil.getString(request, Constants.CMD);
        if (fileEntry.isInTrash() && !cmd.equals(Constants.MOVE_FROM_TRASH)) {
            return null;
        }
        return fileEntry;
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
        return null;
    }
}
Also used : FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 35 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project sw360portal by sw360.

the class UserPortlet method createOrganizations.

public void createOrganizations(PortletRequest request, Iterable<String> departments) throws PortalException, SystemException {
    ImmutableSet<String> headDepartments = FluentIterable.from(departments).transform(department -> extractHeadDept(department)).toSet();
    Map<String, Long> organizationIds = new HashMap<>();
    ServiceContext serviceContext = ServiceContextFactory.getInstance(request);
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long companyId = themeDisplay.getCompanyId();
    for (String headDepartment : headDepartments) {
        long organizationId;
        try {
            organizationId = OrganizationLocalServiceUtil.getOrganizationId(companyId, headDepartment);
        } catch (SystemException e) {
            organizationId = 0;
        }
        if (organizationId == 0) {
            // The organization does not yet exist
            Organization organization = createOrganization(serviceContext, headDepartment, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID);
            organizationId = organization.getOrganizationId();
        }
        organizationIds.put(headDepartment, organizationId);
    }
    for (String department : departments) {
        long organizationId;
        try {
            organizationId = OrganizationLocalServiceUtil.getOrganizationId(companyId, department);
        } catch (SystemException e) {
            organizationId = 0;
        }
        if (organizationId == 0) {
            // The organization does not yet exist
            createOrganization(serviceContext, department, organizationIds.get(extractHeadDept(department)).intValue());
        }
    }
}
Also used : java.util(java.util) CSVRecord(org.apache.commons.csv.CSVRecord) PortletResponseUtil(com.liferay.portal.kernel.portlet.PortletResponseUtil) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) WebKeys(com.liferay.portal.kernel.util.WebKeys) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception) PortalException(com.liferay.portal.kernel.exception.PortalException) PortalUtil(com.liferay.portal.util.PortalUtil) SystemException(com.liferay.portal.kernel.exception.SystemException) Logger(org.apache.log4j.Logger) UserService(org.eclipse.sw360.datahandler.thrift.users.UserService) CSVFormat(org.apache.commons.csv.CSVFormat) FluentIterable(com.google.common.collect.FluentIterable) User(com.liferay.portal.model.User) CSVParser(org.apache.commons.csv.CSVParser) javax.portlet(javax.portlet) UserUtils(org.eclipse.sw360.portal.users.UserUtils) com.liferay.portal.service(com.liferay.portal.service) Sw360Portlet(org.eclipse.sw360.portal.portlets.Sw360Portlet) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) UserCSV(org.eclipse.sw360.portal.users.UserCSV) UserGroup(org.eclipse.sw360.datahandler.thrift.users.UserGroup) TException(org.apache.thrift.TException) UserUtils.getRoleConstantFromUserGroup(org.eclipse.sw360.portal.users.UserUtils.getRoleConstantFromUserGroup) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) CommonUtils(org.eclipse.sw360.datahandler.common.CommonUtils) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest) java.io(java.io) Predicate(com.google.common.base.Predicate) UserCacheHolder(org.eclipse.sw360.portal.users.UserCacheHolder) PortalConstants(org.eclipse.sw360.portal.common.PortalConstants) QueryUtil(com.liferay.portal.kernel.dao.orm.QueryUtil) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction) CSVPrinter(org.apache.commons.csv.CSVPrinter) com.liferay.portal.model(com.liferay.portal.model) SystemException(com.liferay.portal.kernel.exception.SystemException) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Aggregations

PortalException (com.liferay.portal.kernel.exception.PortalException)40 SystemException (com.liferay.portal.kernel.exception.SystemException)25 User (com.liferay.portal.model.User)10 IOException (java.io.IOException)10 User (com.liferay.portal.kernel.model.User)9 Indexable (com.liferay.portal.kernel.search.Indexable)5 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)4 PrincipalException (com.liferay.portal.security.auth.PrincipalException)4 CompanyMaxUsersException (com.liferay.portal.CompanyMaxUsersException)3 ContactBirthdayException (com.liferay.portal.ContactBirthdayException)3 ContactFirstNameException (com.liferay.portal.ContactFirstNameException)3 ContactFullNameException (com.liferay.portal.ContactFullNameException)3 ContactLastNameException (com.liferay.portal.ContactLastNameException)3 DuplicateOpenIdException (com.liferay.portal.DuplicateOpenIdException)3 DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)3 DuplicateUserScreenNameException (com.liferay.portal.DuplicateUserScreenNameException)3 GroupFriendlyURLException (com.liferay.portal.GroupFriendlyURLException)3 ModelListenerException (com.liferay.portal.ModelListenerException)3 NoSuchImageException (com.liferay.portal.NoSuchImageException)3 NoSuchOrganizationException (com.liferay.portal.NoSuchOrganizationException)3