Updates the general settings.<p>

@param cms the cms to use
@param defaulrUri the default URI
@param workplaceServers the workplace server URLs
@param sharedFolder the shared folder URI

@throws CmsException if something goes wrong
430784
public void updateGeneralSettings(
        CmsObject cms,
        String defaulrUri,
        Map<String, CmsSSLMode> workplaceServers,
        String sharedFolder)
    throws CmsException {

        CmsObject clone = OpenCms.initCmsObject(cms);
        clone.getRequestContext().setSiteRoot("");

        // set the shared folder
        if ((sharedFolder == null)
            || sharedFolder.equals("")
            || sharedFolder.equals("/")
            || !sharedFolder.startsWith("/")
            || !sharedFolder.endsWith("/")
            || sharedFolder.startsWith("/sites/")) {
            throw new CmsException(
                Messages.get().container(Messages.ERR_INVALID_PATH_FOR_SHARED_FOLDER_1, sharedFolder));
        }

        m_frozen = false;
        setDefaultUri(clone.readResource(defaulrUri).getRootPath());
        setSharedFolder(clone.readResource(sharedFolder).getRootPath());
        m_workplaceServers = workplaceServers;
        initialize(cms);
        m_frozen = true;
    }
1050093
protected void updateRelationForUndo(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource)
    throws CmsException {

        // type may have changed from non link parseable to link parseable
        CmsResource undoneResource1 = null;
        try {
            // first try to locate the resource by path
            undoneResource1 = createRelations(cms, securityManager, resource.getRootPath());
        } catch (CmsVfsResourceNotFoundException e) {
            // ignore, undone move operation
        }
        // now, in case a move operation has been undone, locate the resource by id
        CmsResource undoneResource2 = securityManager.readResource(
            cms.getRequestContext(),
            resource.getStructureId(),
            CmsResourceFilter.ALL);
        if (!undoneResource2.equals(undoneResource1)) {
            I_CmsResourceType resourceType = getResourceType(resource);
            List<CmsLink> links = null;
            if (resourceType instanceof I_CmsLinkParseable) {
                I_CmsLinkParseable linkParseable = (I_CmsLinkParseable)resourceType;
                if ((undoneResource1 == null) || !undoneResource2.getRootPath().equals(undoneResource1.getRootPath())) {
                    try {
                        links = linkParseable.parseLinks(cms, cms.readFile(undoneResource2));
                    } catch (CmsException e) {
                        if (LOG.isWarnEnabled()) {
                            LOG.warn(e);
                        }
                    } catch (CmsRuntimeException e) {
                        if (LOG.isWarnEnabled()) {
                            LOG.warn(e);
                        }
                    }
                }
            }
            securityManager.updateRelationsForResource(cms.getRequestContext(), undoneResource2, links);
        }
    }
19042
public synchronized void setCms(CmsObject cms) {

        if (m_perThreadCmsObject == null) {
            m_perThreadCmsObject = new ThreadLocal<CmsObject>();
        }
        m_perThreadCmsObject.set(cms);
    }
1045764
private void saveUserSettings() throws CmsException {

        CmsUserSettings settings = new CmsUserSettings(m_user);
        settings.setLocale((Locale)m_language.getValue());
        settings.setStartSite((String)m_site.getValue() + "/");
        settings.setStartProject(m_ou.getValue() + (String)m_project.getValue());
        if (m_visSites) {
            settings.setStartFolder(m_startfolder.getValue().substring(((String)m_site.getValue()).length()));
            if (!CmsStringUtil.isEmptyOrWhitespaceOnly((String)m_startview.getValue())) {
                settings.setStartView((String)m_startview.getValue());
            }
        }
        settings.save(m_cms);
    }
956141
public void addLocalizedFolder(String uri) {

        m_localizedFolders.add(uri);
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_LOCALIZED_1, uri));
        }
    }
687219
public static void loadAndShow(final Runnable finishAction) {

        CmsRpcAction<CmsUserSettingsBean> action = new CmsRpcAction<CmsUserSettingsBean>() {

            @Override
            public void execute() {

                start(200, false);
                CmsCoreProvider.getService().loadUserSettings(this);

            }

            @Override
            protected void onResponse(CmsUserSettingsBean result) {

                stop(false);
                CmsUserSettingsDialog dlg = new CmsUserSettingsDialog(result, finishAction);
                dlg.centerHorizontally(50);
                dlg.initWidth();
            }
        };

        action.execute();

    }
693141
public void addWorkplaceServer(String workplaceServer, String sslmode) {

        if (m_frozen) {
            throw new CmsRuntimeException(Messages.get().container(Messages.ERR_CONFIG_FROZEN_0));
        }
        if (!m_workplaceServers.containsKey(workplaceServer)) {
            m_workplaceServers.put(workplaceServer, CmsSSLMode.getModeFromXML(sslmode));
        }
    }
460524
public void init(CmsObject cms, Locale locale, String requestUri) {

        m_cms = cms;
        m_locale = locale;
        m_requestUri = requestUri;
        m_requestUriFolder = CmsResource.getFolderPath(m_requestUri);
    }
71600
public void updateCmsObject(CmsObject cms) {

        try {
            m_cms = OpenCms.initCmsObject(cms);
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            m_cms = cms;
        }
    }
1353245
public void setWorkplaceManager(CmsWorkplaceManager manager) {

        m_workplaceManager = manager;
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_INIT_FINISHED_0));
        }
    }
234297
public void applyWorkplaceAppSettings() {

        // add site path property to container
        m_container.addContainerProperty(
            CmsResourceTableProperty.PROPERTY_SITE_PATH,
            CmsResourceTableProperty.PROPERTY_SITE_PATH.getColumnType(),
            CmsResourceTableProperty.PROPERTY_SITE_PATH.getDefaultValue());

        // replace the resource name column with the path column
        Object[] visibleCols = m_fileTable.getVisibleColumns();
        for (int i = 0; i < visibleCols.length; i++) {
            if (CmsResourceTableProperty.PROPERTY_RESOURCE_NAME.equals(visibleCols[i])) {
                visibleCols[i] = CmsResourceTableProperty.PROPERTY_SITE_PATH;
            }
        }
        m_fileTable.setVisibleColumns(visibleCols);
        m_fileTable.setColumnCollapsible(CmsResourceTableProperty.PROPERTY_SITE_PATH, false);
        m_fileTable.setColumnHeader(
            CmsResourceTableProperty.PROPERTY_SITE_PATH,
            CmsVaadinUtils.getMessageText(CmsResourceTableProperty.PROPERTY_SITE_PATH.getHeaderKey()));

        // update column visibility according to the latest file explorer settings
        CmsFileExplorerSettings settings;
        try {
            settings = OpenCms.getWorkplaceAppManager().getAppSettings(
                A_CmsUI.getCmsObject(),
                CmsFileExplorerSettings.class);

            setTableState(settings);
        } catch (Exception e) {
            LOG.error("Error while reading file explorer settings from user.", e);
        }
        m_fileTable.setSortContainerPropertyId(CmsResourceTableProperty.PROPERTY_SITE_PATH);
        setActionColumnProperty(CmsResourceTableProperty.PROPERTY_SITE_PATH);
        setMenuBuilder(new CmsResourceContextMenuBuilder());
    }
282561
protected void doLoadNextFile() throws CmsException {

        super.doLoadNextResource();
        if (m_resource == null) {
            return;
        }

        // upgrade the resource to a file
        CmsFile file = m_cms.readFile(m_resource);

        // unmarshal the XML content from the resource, don't use unmarshal(CmsObject, CmsResource)
        // as no support for getting the historic version that has been cached by a CmsHistoryResourceHandler
        // will come from there!
        m_content = CmsXmlContentFactory.unmarshal(m_cms, file, pageContext.getRequest());

        // check if locale is available
        m_contentLocale = m_locale;
        if (!m_content.hasLocale(m_contentLocale)) {
            Iterator<Locale> it = OpenCms.getLocaleManager().getDefaultLocales().iterator();
            while (it.hasNext()) {
                Locale locale = it.next();
                if (m_content.hasLocale(locale)) {
                    // found a matching locale
                    m_contentLocale = locale;
                    break;
                }
            }
        }
    }
276185
public boolean updateAcls(CmsObject cms, CmsResourceImportData resData, CmsResource resource) throws CmsException {

        boolean changed = false;
        Map<CmsUUID, CmsAccessControlEntry> importAces = buildAceMap(resData.getAccessControlEntries());

        String path = cms.getSitePath(resource);
        List<CmsAccessControlEntry> existingAcl = cms.getAccessControlEntries(path, false);
        Map<CmsUUID, CmsAccessControlEntry> existingAces = buildAceMap(existingAcl);
        Set<CmsUUID> keys = new HashSet<>(existingAces.keySet());
        keys.addAll(importAces.keySet());
        for (CmsUUID key : keys) {
            CmsAccessControlEntry existingEntry = existingAces.get(key);
            CmsAccessControlEntry newEntry = importAces.get(key);
            if ((existingEntry == null)
                || (newEntry == null)
                || !existingEntry.withNulledResource().equals(newEntry.withNulledResource())) {
                cms.importAccessControlEntries(resource, resData.getAccessControlEntries());
                changed = true;
                break;
            }
        }
        return changed;
    }
943153
public void updateLastLoginDate(CmsDbContext dbc, CmsUser user) throws CmsException {

        m_monitor.clearUserCache(user);
        // set the last login time to the current time
        user.setLastlogin(System.currentTimeMillis());
        dbc.setAttribute(ATTRIBUTE_LOGIN, user.getName());
        getUserDriver(dbc).writeUser(dbc, user);
        // update cache
        m_monitor.cacheUser(user);

        // invalidate all user dependent caches
        m_monitor.flushCache(
            CmsMemoryMonitor.CacheType.ACL,
            CmsMemoryMonitor.CacheType.GROUP,
            CmsMemoryMonitor.CacheType.ORG_UNIT,
            CmsMemoryMonitor.CacheType.USERGROUPS,
            CmsMemoryMonitor.CacheType.USER_LIST,
            CmsMemoryMonitor.CacheType.PERMISSION,
            CmsMemoryMonitor.CacheType.RESOURCE_LIST);

        // fire user modified event
        Map<String, Object> eventData = new HashMap<String, Object>();
        eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString());
        eventData.put(I_CmsEventListener.KEY_USER_NAME, user.getName());
        eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_WRITE_USER);
        eventData.put(I_CmsEventListener.KEY_USER_CHANGES, Integer.valueOf(CmsUser.FLAG_LAST_LOGIN));
        OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData));
    }
339230
protected static void checkIsFolder(CmsResource resource) throws CmsException {

        if (!isFolder(resource)) {
            throw new CmsIllegalArgumentException(
                Messages.get().container(
                    org.opencms.file.Messages.ERR_REWRITE_LINKS_ROOT_NOT_FOLDER_1,
                    resource.getRootPath()));
        }
    }
1308770
public void setLocale(Locale locale) throws CmsException {

        CmsUserSettings settings = getSettings();
        if (settings != null) {
            settings.setLocale(locale);
            settings.save(m_cms);
            m_messages = Messages.get().getBundle(locale);
        }
    }
930791
public void update(CmsPublishedResource res) {

        try {
            update(res.getStructureId(), res.getRootPath(), res.getType(), res.getState());
        } catch (CmsRuntimeException e) {
            // may happen during import of org.opencms.base module
            LOG.warn(e.getLocalizedMessage(), e);
        }
    }