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