Search in sources :

Example 11 with PortalException

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;
}
Also used : UnsyncByteArrayOutputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayOutputStream) ClassLoaderObjectInputStream(com.liferay.portal.kernel.util.ClassLoaderObjectInputStream) ObjectOutputStream(java.io.ObjectOutputStream) SystemException(com.liferay.portal.kernel.exception.SystemException) UnsyncByteArrayInputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream) PortalException(com.liferay.portal.kernel.exception.PortalException) ObjectInputStream(java.io.ObjectInputStream) ClassLoaderObjectInputStream(com.liferay.portal.kernel.util.ClassLoaderObjectInputStream)

Example 12 with PortalException

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);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 13 with PortalException

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);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 14 with PortalException

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);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 15 with PortalException

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();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WindowStateException(javax.portlet.WindowStateException) FileVersion(com.liferay.portal.kernel.repository.model.FileVersion) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) PortalException(com.liferay.portal.kernel.exception.PortalException) ThemeDisplay(com.liferay.portal.kernel.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

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