use of com.liferay.portal.kernel.exception.PortalException in project liferay-ide by liferay.
the class ClpSerializer method translateThrowable.
public static Throwable translateThrowable(Throwable throwable) {
if (_useReflectionToTranslateThrowable) {
try {
UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream);
objectOutputStream.writeObject(throwable);
objectOutputStream.flush();
objectOutputStream.close();
UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream(unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size());
Thread currentThread = Thread.currentThread();
ClassLoader contextClassLoader = currentThread.getContextClassLoader();
ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream, contextClassLoader);
throwable = (Throwable) objectInputStream.readObject();
objectInputStream.close();
return throwable;
} catch (SecurityException se) {
if (_log.isInfoEnabled()) {
_log.info("Do not use reflection to translate throwable");
}
_useReflectionToTranslateThrowable = false;
} catch (Throwable throwable2) {
_log.error(throwable2, throwable2);
return throwable2;
}
}
Class<?> clazz = throwable.getClass();
String className = clazz.getName();
if (className.equals(PortalException.class.getName())) {
return new PortalException();
}
if (className.equals(SystemException.class.getName())) {
return new SystemException();
}
if (className.equals("org.liferay.jukebox.AlbumNameException")) {
return new org.liferay.jukebox.AlbumNameException();
}
if (className.equals("org.liferay.jukebox.ArtistNameException")) {
return new org.liferay.jukebox.ArtistNameException();
}
if (className.equals("org.liferay.jukebox.DuplicatedAlbumException")) {
return new org.liferay.jukebox.DuplicatedAlbumException();
}
if (className.equals("org.liferay.jukebox.DuplicatedArtistException")) {
return new org.liferay.jukebox.DuplicatedArtistException();
}
if (className.equals("org.liferay.jukebox.DuplicatedSongException")) {
return new org.liferay.jukebox.DuplicatedSongException();
}
if (className.equals("org.liferay.jukebox.NoSuchAlbumException")) {
return new org.liferay.jukebox.NoSuchAlbumException();
}
if (className.equals("org.liferay.jukebox.NoSuchArtistException")) {
return new org.liferay.jukebox.NoSuchArtistException();
}
if (className.equals("org.liferay.jukebox.NoSuchSongException")) {
return new org.liferay.jukebox.NoSuchSongException();
}
if (className.equals("org.liferay.jukebox.SongNameException")) {
return new org.liferay.jukebox.SongNameException();
}
if (className.equals("org.liferay.jukebox.NoSuchAlbumException")) {
return new org.liferay.jukebox.NoSuchAlbumException();
}
if (className.equals("org.liferay.jukebox.NoSuchArtistException")) {
return new org.liferay.jukebox.NoSuchArtistException();
}
if (className.equals("org.liferay.jukebox.NoSuchSongException")) {
return new org.liferay.jukebox.NoSuchSongException();
}
return throwable;
}
use of com.liferay.portal.kernel.exception.PortalException in project liferay-blade-samples by liferay.
the class LogAuthFailure method onFailureByScreenName.
@Override
public void onFailureByScreenName(long companyId, String screenName, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {
try {
User user = UserLocalServiceUtil.getUserByScreenName(companyId, screenName);
int failures = user.getFailedLoginAttempts();
_log.log(LogService.LOG_INFO, "onFailureByScreenName: " + screenName + " 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 LogAuthFailure 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);
int failures = user.getFailedLoginAttempts();
_log.log(LogService.LOG_INFO, "onFailureByUserId: userId " + userId + " 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 onFailureByScreenName.
@Override
public void onFailureByScreenName(long companyId, String screenName, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {
try {
User user = UserLocalServiceUtil.getUserByScreenName(companyId, screenName);
boolean lockout = user.isLockout();
_log.log(LogService.LOG_INFO, "onFailureByScreenName: " + screenName + " 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 getURL.
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {
HttpServletRequest servletRequest = _portal.getHttpServletRequest(portletRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
FileEntry fileEntry = _retrieveFile(servletRequest);
PortletURL portletURL = PortletURLFactoryUtil.create(servletRequest, "blade_document_action_portlet_BladeDocumentActionPortlet", themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
String fileName = fileEntry.getFileName();
String mimeType = fileEntry.getMimeType();
String version = fileEntry.getVersion();
String createdDate = String.valueOf(fileEntry.getCreateDate());
String createdUserName = fileEntry.getUserName();
String statusLabel = null;
try {
FileVersion fileVersion = fileEntry.getLatestFileVersion();
int status = fileVersion.getStatus();
statusLabel = WorkflowConstants.getStatusLabel(status);
} catch (PortalException pe) {
_log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
}
portletURL.setParameter("fileName", fileName);
portletURL.setParameter("mimeType", mimeType);
portletURL.setParameter("version", version);
portletURL.setParameter("statusLabel", statusLabel);
portletURL.setParameter("createdDate", createdDate);
portletURL.setParameter("createdUserName", createdUserName);
try {
portletURL.setWindowState(LiferayWindowState.POP_UP);
} catch (WindowStateException wse) {
_log.log(LogService.LOG_ERROR, wse.getMessage(), wse);
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("javascript:Liferay.Util.openWindow(");
stringBuilder.append("{dialog: {cache: false,width:800,modal: true},");
stringBuilder.append("title: 'basic information',id: ");
stringBuilder.append("'testPopupIdUnique',uri: '");
stringBuilder.append(portletURL.toString() + "'});");
return stringBuilder.toString();
}
Aggregations