Example usage for java.lang ClassCastException getLocalizedMessage

List of usage examples for java.lang ClassCastException getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang ClassCastException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.matrix.androidsdk.fragments.MatrixMessageListFragment.java

@Override
public RoomPreviewData getRoomPreviewData() {
    if (null != getActivity()) {
        // test if the listener has bee retrieved
        if (null == mRoomPreviewDataListener) {
            try {
                mRoomPreviewDataListener = (IRoomPreviewDataListener) getActivity();
            } catch (ClassCastException e) {
                Log.e(LOG_TAG, "getRoomPreviewData failed with " + e.getLocalizedMessage());
            }/*  ww w  . j  ava  2  s.  com*/
        }

        if (null != mRoomPreviewDataListener) {
            return mRoomPreviewDataListener.getRoomPreviewData();
        }
    }

    return null;
}

From source file:org.opencms.db.CmsUserSettings.java

/**
 * Initializes the user settings with the given users setting parameters.<p>
 * //from   w  w w .j av  a  2  s.  co  m
 * @param user the current CmsUser
 */
public void init(CmsUser user) {

    m_user = user;

    // try to initialize the User Settings with the values stored in the user object.
    // if no values are found, the default user settings will be used.

    // workplace button style
    try {
        m_workplaceButtonStyle = ((Integer) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_WORKPLACEGENERALOPTIONS
                        + CmsWorkplaceConfiguration.N_BUTTONSTYLE)).intValue();
    } catch (Throwable t) {
        m_workplaceButtonStyle = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getWorkplaceButtonStyle();
    }
    // workplace time warp setting
    Object timeWarpObj = m_user.getAdditionalInfo(ADDITIONAL_INFO_TIMEWARP);
    try {
        m_timeWarp = ((Long) timeWarpObj).longValue();
    } catch (ClassCastException e) {
        try {
            m_timeWarp = Long.parseLong((String) timeWarpObj);
        } catch (Throwable t) {
            m_timeWarp = CmsContextInfo.CURRENT_TIME;
        }
    } catch (Throwable t) {
        m_timeWarp = CmsContextInfo.CURRENT_TIME;
    }
    // workplace report type
    m_workplaceReportType = (String) m_user.getAdditionalInfo(PREFERENCES
            + CmsWorkplaceConfiguration.N_WORKPLACEGENERALOPTIONS + CmsWorkplaceConfiguration.N_REPORTTYPE);
    if (m_workplaceReportType == null) {
        m_workplaceReportType = OpenCms.getWorkplaceManager().getDefaultUserSettings().getWorkplaceReportType();
    }
    // workplace list all projects
    try {
        m_listAllProjects = ((Boolean) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_WORKPLACEGENERALOPTIONS
                        + CmsWorkplaceConfiguration.N_LISTALLPROJECTS)).booleanValue();
    } catch (Throwable t) {
        m_listAllProjects = OpenCms.getWorkplaceManager().getDefaultUserSettings().getListAllProjects();
    }
    // workplace show publish notification
    try {
        m_showPublishNotification = ((Boolean) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_WORKPLACEGENERALOPTIONS
                        + CmsWorkplaceConfiguration.N_PUBLISHNOTIFICATION)).booleanValue();
    } catch (Throwable t) {
        m_showPublishNotification = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getShowPublishNotification();
    }
    // workplace upload applet mode
    setUploadVariant(String.valueOf(m_user.getAdditionalInfo(PREFERENCES
            + CmsWorkplaceConfiguration.N_WORKPLACEGENERALOPTIONS + CmsWorkplaceConfiguration.N_UPLOADAPPLET)));

    // locale
    Object obj = m_user.getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_WORKPLACESTARTUPSETTINGS
            + CmsWorkplaceConfiguration.N_LOCALE);
    if (obj == null) {
        m_locale = null;
    } else {
        m_locale = CmsLocaleManager.getLocale(String.valueOf(obj));
    }
    if (m_locale == null) {
        m_locale = OpenCms.getWorkplaceManager().getDefaultUserSettings().getLocale();
    }
    // start project
    try {
        m_project = (String) m_user.getAdditionalInfo(PREFERENCES
                + CmsWorkplaceConfiguration.N_WORKPLACESTARTUPSETTINGS + CmsWorkplaceConfiguration.N_PROJECT);
    } catch (Throwable t) {
        m_project = null;
    }
    if (m_project == null) {
        m_project = OpenCms.getWorkplaceManager().getDefaultUserSettings().getStartProject();
        String ou = user.getOuFqn();
        if (ou == null) {
            ou = "";
        }
        m_project = user.getOuFqn() + m_project;
    }
    // start view
    m_view = (String) m_user.getAdditionalInfo(PREFERENCES
            + CmsWorkplaceConfiguration.N_WORKPLACESTARTUPSETTINGS + CmsWorkplaceConfiguration.N_WORKPLACEVIEW);
    if (m_view == null) {
        m_view = OpenCms.getWorkplaceManager().getDefaultUserSettings().getStartView();
    }
    // explorer button style
    try {
        m_explorerButtonStyle = ((Integer) m_user.getAdditionalInfo(PREFERENCES
                + CmsWorkplaceConfiguration.N_EXPLORERGENERALOPTIONS + CmsWorkplaceConfiguration.N_BUTTONSTYLE))
                        .intValue();
    } catch (Throwable t) {
        m_explorerButtonStyle = OpenCms.getWorkplaceManager().getDefaultUserSettings().getExplorerButtonStyle();
    }
    // explorer file entries        
    try {
        m_explorerFileEntries = ((Integer) m_user.getAdditionalInfo(PREFERENCES
                + CmsWorkplaceConfiguration.N_EXPLORERGENERALOPTIONS + CmsWorkplaceConfiguration.N_ENTRIES))
                        .intValue();
    } catch (Throwable t) {
        m_explorerFileEntries = OpenCms.getWorkplaceManager().getDefaultUserSettings().getExplorerFileEntries();
    }
    // explorer settings
    try {
        m_explorerSettings = ((Integer) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_EXPLORERGENERALOPTIONS
                        + CmsWorkplaceConfiguration.N_EXPLORERDISPLAYOPTIONS)).intValue();
    } catch (Throwable t) {
        m_explorerSettings = OpenCms.getWorkplaceManager().getDefaultUserSettings().getExplorerSettings();
    }
    // dialog file copy mode
    try {
        m_dialogFileCopy = CmsResourceCopyMode.valueOf(((Integer) m_user.getAdditionalInfo(PREFERENCES
                + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS + CmsWorkplaceConfiguration.N_FILECOPY))
                        .intValue());
    } catch (Throwable t) {
        m_dialogFileCopy = OpenCms.getWorkplaceManager().getDefaultUserSettings().getDialogCopyFileMode();
    }
    // dialog folder copy mode
    try {
        m_dialogFolderCopy = CmsResourceCopyMode.valueOf(((Integer) m_user.getAdditionalInfo(PREFERENCES
                + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS + CmsWorkplaceConfiguration.N_FOLDERCOPY))
                        .intValue());
    } catch (Throwable t) {
        m_dialogFolderCopy = OpenCms.getWorkplaceManager().getDefaultUserSettings().getDialogCopyFolderMode();
    }
    // dialog file delete mode
    try {
        m_dialogFileDelete = CmsResourceDeleteMode.valueOf(((Integer) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS
                        + CmsWorkplaceConfiguration.N_FILEDELETION)).intValue());
    } catch (Throwable t) {
        m_dialogFileDelete = OpenCms.getWorkplaceManager().getDefaultUserSettings().getDialogDeleteFileMode();
    }
    // dialog direct publish mode
    try {
        m_dialogDirectpublish = ((Boolean) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS
                        + CmsWorkplaceConfiguration.N_DIRECTPUBLISH)).booleanValue();
    } catch (Throwable t) {
        m_dialogDirectpublish = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getDialogPublishSiblings();
    }
    // dialog show lock mode
    try {
        m_showLock = ((Boolean) m_user.getAdditionalInfo(PREFERENCES
                + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS + CmsWorkplaceConfiguration.N_SHOWLOCK))
                        .booleanValue();
    } catch (Throwable t) {
        m_showLock = OpenCms.getWorkplaceManager().getDefaultUserSettings().getDialogShowLock();
    }
    // dialog show export settings mode
    try {
        m_showExportSettings = ((Boolean) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS
                        + CmsWorkplaceConfiguration.N_SHOWEXPORTSETTINGS)).booleanValue();
    } catch (Throwable t) {
        m_showExportSettings = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getDialogShowExportSettings();
    }
    // dialog permissions inheriting mode
    try {
        m_dialogPermissionsInheritOnFolder = ((Boolean) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS
                        + CmsWorkplaceConfiguration.N_PERMISSIONSINHERITONFOLDER)).booleanValue();
    } catch (Throwable t) {
        m_dialogPermissionsInheritOnFolder = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getDialogPermissionsInheritOnFolder();
    }
    // dialog expand inherited permissions mode
    try {
        m_dialogExpandInheritedPermissions = ((Boolean) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS
                        + CmsWorkplaceConfiguration.N_EXPANDPERMISSIONSINHERITED)).booleanValue();
    } catch (Throwable t) {
        m_dialogExpandInheritedPermissions = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getDialogExpandInheritedPermissions();
    }
    // dialog expand users permissions mode
    try {
        m_dialogExpandUserPermissions = ((Boolean) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_DIALOGSDEFAULTSETTINGS
                        + CmsWorkplaceConfiguration.N_EXPANDPERMISSIONSUSER)).booleanValue();
    } catch (Throwable t) {
        m_dialogExpandUserPermissions = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getDialogExpandUserPermissions();
    }
    // editor button style
    try {
        m_editorButtonStyle = ((Integer) m_user.getAdditionalInfo(PREFERENCES
                + CmsWorkplaceConfiguration.N_EDITORGENERALOPTIONS + CmsWorkplaceConfiguration.N_BUTTONSTYLE))
                        .intValue();
    } catch (Throwable t) {
        m_editorButtonStyle = OpenCms.getWorkplaceManager().getDefaultUserSettings().getEditorButtonStyle();
    }
    // direct edit button style
    try {
        m_directeditButtonStyle = ((Integer) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_EDITORGENERALOPTIONS
                        + CmsWorkplaceConfiguration.N_DIRECTEDITSTYLE)).intValue();
    } catch (Throwable t) {
        m_directeditButtonStyle = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getDirectEditButtonStyle();
    }
    // editor settings
    m_editorSettings = new TreeMap<String, String>();
    Iterator<String> itKeys = m_user.getAdditionalInfo().keySet().iterator();
    while (itKeys.hasNext()) {
        String key = itKeys.next();
        if (key.startsWith(PREFERENCES + CmsWorkplaceConfiguration.N_EDITORPREFERREDEDITORS)) {
            String editKey = key
                    .substring((PREFERENCES + CmsWorkplaceConfiguration.N_EDITORPREFERREDEDITORS).length());
            m_editorSettings.put(editKey, m_user.getAdditionalInfo(key).toString());
        }
    }
    if (m_editorSettings.isEmpty()) {
        m_editorSettings = new TreeMap<String, String>(
                OpenCms.getWorkplaceManager().getDefaultUserSettings().getEditorSettings());

    }
    // start gallery settings 
    m_startGalleriesSettings = new TreeMap<String, String>();
    Iterator<String> gKeys = m_user.getAdditionalInfo().keySet().iterator();
    while (gKeys.hasNext()) {
        String key = gKeys.next();
        if (key.startsWith(PREFERENCES + CmsWorkplaceConfiguration.N_STARTGALLERIES)) {
            String editKey = key.substring((PREFERENCES + CmsWorkplaceConfiguration.N_STARTGALLERIES).length());
            m_startGalleriesSettings.put(editKey, m_user.getAdditionalInfo(key).toString());
        }
    }
    if (m_startGalleriesSettings.isEmpty()) {
        m_startGalleriesSettings = new TreeMap<String, String>();
    }

    // start site
    m_startSite = (String) m_user.getAdditionalInfo(
            PREFERENCES + CmsWorkplaceConfiguration.N_WORKPLACESTARTUPSETTINGS + I_CmsXmlConfiguration.N_SITE);
    if (m_startSite == null) {
        m_startSite = OpenCms.getWorkplaceManager().getDefaultUserSettings().getStartSite();
    }
    // start folder, we use the setter here for default logic in case of illegal folder string:
    String startFolder = (String) m_user.getAdditionalInfo(PREFERENCES
            + CmsWorkplaceConfiguration.N_WORKPLACESTARTUPSETTINGS + CmsWorkplaceConfiguration.N_FOLDER);
    if (startFolder == null) {
        startFolder = OpenCms.getWorkplaceManager().getDefaultUserSettings().getStartFolder();
    }
    setStartFolder(startFolder);

    // restrict explorer folder view
    try {
        m_restrictExplorerView = ((Boolean) m_user
                .getAdditionalInfo(PREFERENCES + CmsWorkplaceConfiguration.N_WORKPLACESTARTUPSETTINGS
                        + CmsWorkplaceConfiguration.N_RESTRICTEXPLORERVIEW)).booleanValue();
    } catch (Throwable t) {
        m_restrictExplorerView = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getRestrictExplorerView();
    }
    // workplace search
    m_workplaceSearchIndexName = OpenCms.getWorkplaceManager().getDefaultUserSettings()
            .getWorkplaceSearchIndexName();

    m_workplaceSearchViewStyle = CmsSearchResultStyle.valueOf((String) m_user.getAdditionalInfo(PREFERENCES
            + CmsWorkplaceConfiguration.N_WORKPLACESEARCH + CmsWorkplaceConfiguration.N_SEARCHVIEWSTYLE));
    if (m_workplaceSearchViewStyle == null) {
        m_workplaceSearchViewStyle = OpenCms.getWorkplaceManager().getDefaultUserSettings()
                .getWorkplaceSearchViewStyle();
    }
    // synchronize settings
    try {
        boolean enabled = ((Boolean) m_user.getAdditionalInfo(PREFERENCES + SYNC_SETTINGS + SYNC_ENABLED))
                .booleanValue();
        String destination = (String) m_user.getAdditionalInfo(PREFERENCES + SYNC_SETTINGS + SYNC_DESTINATION);
        List<String> vfsList = CmsStringUtil.splitAsList(
                (String) m_user.getAdditionalInfo(PREFERENCES + SYNC_SETTINGS + SYNC_VFS_LIST), '|');
        m_synchronizeSettings = new CmsSynchronizeSettings();
        m_synchronizeSettings.setEnabled(enabled);
        m_synchronizeSettings.setDestinationPathInRfs(destination);
        m_synchronizeSettings.setSourceListInVfs(vfsList);
    } catch (Throwable t) {
        // default is to disable the synchronize settings
        m_synchronizeSettings = null;
    }
    // upload applet client folder path
    m_uploadAppletClientFolder = (String) m_user.getAdditionalInfo(ADDITIONAL_INFO_UPLOADAPPLET_CLIENTFOLDER);

    try {
        save(null);
    } catch (CmsException e) {
        // ignore
        if (LOG.isWarnEnabled()) {
            LOG.warn(e.getLocalizedMessage(), e);
        }
    }
}