Saves the inheritance group.<p>

@param resource the inheritance group resource
@param inheritanceContainer the inherited group container data

@throws CmsException if something goes wrong
760146
private void saveInheritanceGroup(CmsResource resource, CmsInheritanceContainer inheritanceContainer)
    throws CmsException {

        CmsObject cms = getCmsObject();
        CmsFile file = cms.readFile(resource);
        CmsXmlContent document = CmsXmlContentFactory.unmarshal(cms, file);

        for (Locale docLocale : document.getLocales()) {
            document.removeLocale(docLocale);
        }
        Locale locale = Locale.ENGLISH;
        document.addLocale(cms, locale);
        document.getValue("Title", locale).setStringValue(cms, inheritanceContainer.getTitle());
        document.getValue("Description", locale).setStringValue(cms, inheritanceContainer.getDescription());
        document.getValue("ConfigName", locale).setStringValue(cms, inheritanceContainer.getName());
        byte[] content = document.marshal();
        file.setContents(content);
        cms.writeFile(file);
    }
1295233
public static void handleCmsException(CmsException e) {

        if (e instanceof CmsVfsResourceNotFoundException) {
            throw new CmisObjectNotFoundException(e.getLocalizedMessage(), e);
        } else if (e instanceof CmsSecurityException) {
            throw new CmisUnauthorizedException(e.getLocalizedMessage(), e);
        } else {
            throw new CmisRuntimeException(e.getLocalizedMessage(), e);
        }
    }
749135
protected CmsPublishResource createPublishResource(CmsResource resource) throws CmsException {

        CmsResourceUtil resUtil = new CmsResourceUtil(m_cms, resource);
        CmsPermissionInfo permissionInfo = OpenCms.getADEManager().getPermissionInfo(m_cms, resource, null);

        String typeName = CmsIconUtil.getDisplayType(m_cms, resource);
        String detailTypeName = CmsResourceIcon.getDefaultFileOrDetailType(m_cms, resource);
        CmsPublishResource pubResource = new CmsPublishResource(
            resource.getStructureId(),
            resUtil.getFullPath(),
            resUtil.getTitle(),
            typeName,
            resource.getState(),
            permissionInfo,
            resource.getDateLastModified(),
            resUtil.getUserLastModified(),
            CmsVfsService.formatDateTime(m_cms, resource.getDateLastModified()),
            false,
            null,
            new ArrayList<CmsPublishResource>());
        pubResource.setBigIconClasses(CmsIconUtil.getIconClasses(typeName, resource.getName(), false));
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(detailTypeName)) {
            pubResource.setSmallIconClasses(CmsIconUtil.getIconClasses(detailTypeName, null, true));
        }
        return pubResource;
    }
676831
public void saveGroupcontainer(
        final CmsGroupContainer groupContainer,
        final CmsGroupContainerElementPanel groupContainerElement) {

        if (getGroupcontainer() != null) {
            CmsRpcAction<CmsGroupContainerSaveResult> action = new CmsRpcAction<CmsGroupContainerSaveResult>() {

                /**
                 * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
                 */
                @Override
                public void execute() {

                    start(0, true);
                    getContainerpageService().saveGroupContainer(
                        getData().getRpcContext(),
                        getData().getDetailId(),
                        getRequestParams(),
                        groupContainer,
                        getPageState(),
                        getLocale(),
                        this);
                }

                /**
                 * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
                 */
                @Override
                protected void onResponse(CmsGroupContainerSaveResult saveResult) {

                    stop(false);
                    Map<String, CmsContainerElementData> elementData = saveResult.getElementData();
                    m_elements.putAll(elementData);
                    try {
                        replaceContainerElement(groupContainerElement, elementData.get(groupContainerElement.getId()));
                    } catch (Exception e) {
                        CmsDebugLog.getInstance().printLine("Error replacing group container element");
                    }
                    addToRecentList(groupContainerElement.getId(), null);
                    CmsNotification.get().send(
                        Type.NORMAL,
                        Messages.get().key(Messages.GUI_NOTIFICATION_GROUP_CONTAINER_SAVED_0));
                    List<CmsRemovedElementStatus> removedElements = saveResult.getRemovedElements();
                    for (CmsRemovedElementStatus removedElement : removedElements) {
                        askWhetherRemovedElementShouldBeDeleted(removedElement);
                    }

                }
            };
            action.execute();

        }
    }
1316631
public void writeContainerPage(CmsObject cms, CmsContainerPageBean cntPage) throws CmsException {

        // keep unused containers
        CmsContainerPageBean savePage = cleanupContainersContainers(cms, cntPage);
        savePage = removeEmptyContainers(cntPage);
        // Replace existing locales with master locale
        for (Locale locale : getLocales()) {
            removeLocale(locale);
        }
        Locale masterLocale = CmsLocaleManager.MASTER_LOCALE;
        addLocale(cms, masterLocale);

        // add the nodes to the raw XML structure
        Element parent = getLocaleNode(masterLocale);
        saveContainerPage(cms, parent, savePage);
        initDocument(m_document, m_encoding, m_contentDefinition);
    }
482716
public void load(CmsObject cms, CmsResource resource) throws CmsException {

        CmsFile file = cms.readFile(resource);
        CmsObject rootCms = OpenCms.initCmsObject(cms);
        rootCms.getRequestContext().setSiteRoot("");
        CmsXmlContent content = CmsXmlContentFactory.unmarshal(cms, file);
        Locale en = new Locale("en");
        for (I_CmsXmlContentValue value : content.getValues(N_INCLUDE, en)) {
            String include = value.getStringValue(rootCms);
            if (!CmsStringUtil.isEmpty(include)) {
                m_includes.add(include);
            }
        }
        for (I_CmsXmlContentValue value : content.getValues(N_EXCLUDE, en)) {
            String exclude = value.getStringValue(rootCms);
            if (!CmsStringUtil.isEmpty(exclude)) {
                m_excludes.add(exclude);
            }
        }
        I_CmsXmlContentValue robotsValue = content.getValue(N_MODE, en);
        m_mode = robotsValue.getStringValue(rootCms);

        I_CmsXmlContentValue robotsTxtTextValue = content.getValue(N_ROBOTS_TXT_TEXT, en);
        if (robotsTxtTextValue != null) {
            m_robotsTxtText = robotsTxtTextValue.getStringValue(rootCms);
        }

        I_CmsXmlContentValue computeContPageDates = content.getValue(N_COMPUTE_CONTAINER_PAGE_DATES, en);
        if (computeContPageDates != null) {
            m_computeContainerPageDates = Boolean.parseBoolean(computeContPageDates.getStringValue(rootCms));
        }

        I_CmsXmlContentValue generatorClassValue = content.getValue(N_GENERATOR_CLASS, en);
        if (generatorClassValue != null) {
            m_generatorClassName = generatorClassValue.getStringValue(rootCms);
        }

        I_CmsXmlContentValue cacheValue = content.getValue(N_CACHE, en);
        if (cacheValue != null) {
            m_useCache = Boolean.parseBoolean(cacheValue.getStringValue(rootCms));
        }

        I_CmsXmlContentValue serverUrlValue = content.getValue(N_SERVER_URL, en);
        if (serverUrlValue != null) {
            m_serverUrl = serverUrlValue.getStringValue(rootCms);
        }
    }
582301
public void init(CmsAccountsApp app, CmsObject cms, CmsUser user, List<CmsGroup> groups) {

        m_app = app;
        if (m_container == null) {
            m_container = new IndexedContainer();

            for (TableProperty prop : TableProperty.values()) {
                m_container.addContainerProperty(prop, prop.getType(), prop.getDefault());
                setColumnHeader(prop, prop.getName());
            }
            m_app.addGroupContainerProperties(m_container);
            setContainerDataSource(m_container);
            setItemIconPropertyId(TableProperty.Icon);
            setRowHeaderMode(RowHeaderMode.ICON_ONLY);

            setColumnWidth(null, 40);
            setSelectable(false);
            setMultiSelect(false);
            setVisibleColumns(TableProperty.Name, TableProperty.OU);

        }
        m_container.removeAllItems();

        for (CmsGroup group : groups) {
            Item item = m_container.addItem(group);
            m_app.fillGroupItem(item, group, new ArrayList<CmsGroup>());
        }

    }
1204206
public static CmsLockActionRecord ensureLock(CmsObject cms, CmsResource resource) throws CmsException {

        LockChange change = LockChange.unchanged;
        List<CmsResource> blockingResources = cms.getBlockingLockedResources(resource);
        if ((blockingResources != null) && !blockingResources.isEmpty()) {
            throw new CmsException(
                Messages.get().container(
                    Messages.ERR_RESOURCE_HAS_BLOCKING_LOCKED_CHILDREN_1,
                    cms.getSitePath(resource)));
        }
        CmsUser user = cms.getRequestContext().getCurrentUser();
        CmsLock lock = cms.getLock(resource);
        if (!lock.isOwnedBy(user)) {
            cms.lockResourceTemporary(resource);
            change = LockChange.locked;
            lock = cms.getLock(resource);
        } else if (!lock.isOwnedInProjectBy(user, cms.getRequestContext().getCurrentProject())) {
            cms.changeLock(resource);
            change = LockChange.changed;
            lock = cms.getLock(resource);
        }
        return new CmsLockActionRecord(lock, change);
    }
1359951
public static base_response save(nitro_service client, cachecontentgroup resource) throws Exception {
		cachecontentgroup saveresource = new cachecontentgroup();
		saveresource.name = resource.name;
		return saveresource.perform_operation(client,"save");
	}
79436
public void startEditingGroupcontainer(
        final CmsGroupContainerElementPanel groupContainer,
        final boolean isElementGroup) {

        removeEditButtonsPositionTimer();
        I_CmsSimpleCallback<Boolean> callback = new I_CmsSimpleCallback<Boolean>() {

            public void execute(Boolean arg) {

                if (arg.booleanValue()) {
                    if (isElementGroup) {
                        m_groupEditor = CmsGroupContainerEditor.openGroupcontainerEditor(
                            groupContainer,
                            CmsContainerpageController.this,
                            m_handler);
                    } else {
                        m_groupEditor = CmsInheritanceContainerEditor.openInheritanceContainerEditor(
                            groupContainer,
                            CmsContainerpageController.this,
                            m_handler);
                    }
                } else {
                    CmsNotification.get().send(
                        Type.WARNING,
                        Messages.get().key(Messages.GUI_NOTIFICATION_UNABLE_TO_LOCK_0));
                }
            }
        };
        if ((m_groupEditor == null) && (groupContainer.isNew())) {
            callback.execute(Boolean.TRUE);
        } else {
            lockContainerpage(callback);
        }

    }
601394
private void init(CmsResource resource, CmsObject cms) {

        List<CmsProperty> properties;

        try {
            properties = cms.readPropertyObjects(resource, false);
        } catch (CmsException e) {
            m_priority = 0;
            m_title = "";
            return;
        }

        try {
            m_priority = Integer.parseInt(
                CmsProperty.get(CmsPriorityResourceCollector.PROPERTY_PRIORITY, properties).getValue());
        } catch (NumberFormatException e) {
            m_priority = CmsPriorityResourceCollector.PRIORITY_STANDARD;
        }

        m_title = CmsProperty.get(CmsPropertyDefinition.PROPERTY_TITLE, properties).getValue();
        if (CmsStringUtil.isEmpty(m_title)) {
            m_title = "";
        }
    }
487195
public void setUserGroups(CmsObject cms) {

        if (getUser() != null) {
            try {
                m_groups = cms.getGroupsOfUser(getUser().getName(), false);
            } catch (CmsException e) {
                // failed to set user groups
            }
        }
    }
306695
public void initialize(CmsObject cms) throws CmsException {

        CmsUUID id = m_entry.getId();
        CmsResource resource = cms.readResource(id, CmsResourceFilter.IGNORE_EXPIRATION);
        m_resource = resource;
        CmsResource defaultFile = resource;
        if (resource.isFolder()) {
            defaultFile = cms.readDefaultFile(resource, CmsResourceFilter.IGNORE_EXPIRATION);
        }
        CmsLocaleGroup localeGroup = cms.getLocaleGroupService().readLocaleGroup(defaultFile);
        CmsResource primary = localeGroup.getPrimaryResource();
        CmsProperty noTranslationProp = cms.readPropertyObject(
            primary,
            CmsPropertyDefinition.PROPERTY_LOCALE_NOTRANSLATION,
            false);
        m_noTranslation = noTranslationProp.getValue();
        CmsUUID defaultFileId = (defaultFile != null) ? defaultFile.getStructureId() : null;
        m_isCopyable = (defaultFile != null) && CmsResourceTypeXmlContainerPage.isContainerPage(defaultFile);
        Collection<CmsResource> resourcesForTargetLocale = localeGroup.getResourcesForLocale(m_otherLocale);
        if (!resourcesForTargetLocale.isEmpty()) {
            m_linkedResource = resourcesForTargetLocale.iterator().next();
            if (primary.getStructureId().equals(m_resource.getStructureId())
                || primary.getStructureId().equals(defaultFileId)
                || primary.getStructureId().equals(m_linkedResource.getStructureId())) {
                m_isDirectLink = true;
            }
        }
    }
285503
public void setCacheGroupContainer(String key, CmsXmlGroupContainer groupContainer, boolean online) {

        try {
            m_lock.writeLock().lock();
            if (online) {
                m_groupContainersOnline.put(key, groupContainer);
                if (LOG.isDebugEnabled()) {
                    LOG.debug(
                        Messages.get().getBundle().key(
                            Messages.LOG_DEBUG_CACHE_SET_ONLINE_2,
                            new Object[] {key, groupContainer}));
                }
            } else {
                m_groupContainersOffline.put(key, groupContainer);
                if (LOG.isDebugEnabled()) {
                    LOG.debug(
                        Messages.get().getBundle().key(
                            Messages.LOG_DEBUG_CACHE_SET_OFFLINE_2,
                            new Object[] {key, groupContainer}));
                }
            }
        } finally {
            m_lock.writeLock().unlock();
        }
    }
1292599
protected void saveContainerPage(CmsObject cms, Element parent, CmsContainerPageBean cntPage) throws CmsException {

        parent.clearContent();

        // save containers in a defined order
        List<String> containerNames = new ArrayList<String>(cntPage.getNames());
        Collections.sort(containerNames);

        for (String containerName : containerNames) {
            CmsContainerBean container = cntPage.getContainers().get(containerName);

            // the container
            Element cntElement = parent.addElement(XmlNode.Containers.name());
            cntElement.addElement(XmlNode.Name.name()).addCDATA(container.getName());
            cntElement.addElement(XmlNode.Type.name()).addCDATA(container.getType());
            if (container.isNestedContainer()) {
                cntElement.addElement(XmlNode.ParentInstanceId.name()).addCDATA(container.getParentInstanceId());
            }
            if (container.isRootContainer()) {
                cntElement.addElement(XmlNode.IsRootContainer.name()).addText(Boolean.TRUE.toString());
            }

            // the elements
            for (CmsContainerElementBean element : container.getElements()) {
                Element elemElement = cntElement.addElement(XmlNode.Elements.name());

                // the element
                Element uriElem = elemElement.addElement(XmlNode.Uri.name());
                CmsResource uriRes = fillResource(cms, uriElem, element.getId());
                Element formatterElem = elemElement.addElement(XmlNode.Formatter.name());
                fillResource(cms, formatterElem, element.getFormatterId());
                if (element.isCreateNew()) {
                    Element createNewElem = elemElement.addElement(XmlNode.CreateNew.name());
                    createNewElem.addText(Boolean.TRUE.toString());
                }
                // the properties
                Map<String, String> properties = element.getIndividualSettings();
                Map<String, CmsXmlContentProperty> propertiesConf = OpenCms.getADEManager().getElementSettings(
                    cms,
                    uriRes);

                CmsXmlContentPropertyHelper.saveProperties(cms, elemElement, properties, propertiesConf);
            }
        }
    }
1098172
private void saveProperties(String resourcePath, Map<String, String> properties) throws CmsException {

        CmsResource resource;
        CmsObject cms = getCmsObject();
        int pos = resourcePath.indexOf("?");
        String resName = resourcePath;
        if (pos > -1) {
            resName = resourcePath.substring(0, pos);
        }
        resource = cms.readResource(resName);

        if (properties != null) {
            for (Entry<String, String> entry : properties.entrySet()) {
                String propertyName = entry.getKey();
                String propertyValue = entry.getValue();
                if (CmsStringUtil.isEmptyOrWhitespaceOnly(propertyValue)) {
                    propertyValue = "";
                }
                try {
                    CmsProperty currentProperty = cms.readPropertyObject(resource, propertyName, false);
                    // detect if property is a null property or not
                    if (currentProperty.isNullProperty()) {
                        // create new property object and set key and value
                        currentProperty = new CmsProperty();
                        currentProperty.setName(propertyName);
                        if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
                            // set structure value
                            currentProperty.setStructureValue(propertyValue);
                            currentProperty.setResourceValue(null);
                        } else {
                            // set resource value
                            currentProperty.setStructureValue(null);
                            currentProperty.setResourceValue(propertyValue);
                        }
                    } else if (currentProperty.getStructureValue() != null) {
                        // structure value has to be updated
                        currentProperty.setStructureValue(propertyValue);
                        currentProperty.setResourceValue(null);
                    } else {
                        // resource value has to be updated
                        currentProperty.setStructureValue(null);
                        currentProperty.setResourceValue(propertyValue);
                    }
                    CmsLock lock = cms.getLock(resource);
                    if (lock.isUnlocked()) {
                        // lock resource before operation
                        cms.lockResource(resName);
                    }
                    // write the property to the resource
                    cms.writePropertyObject(resName, currentProperty);
                    // unlock the resource
                    cms.unlockResource(resName);
                } catch (CmsException e) {
                    // writing the property failed, log error
                    log(e.getLocalizedMessage());
                }
            }
        }
    }
61195
public void save(CmsObject cms, CmsContainerPageBean cntPage) throws CmsException {

        save(cms, cntPage, false);
    }