001/*
002 *  Copyright 2018 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.contenttypeseditor.edition.clientsideelement;
017
018import java.util.Map;
019
020import org.apache.avalon.framework.service.ServiceException;
021import org.apache.avalon.framework.service.ServiceManager;
022
023import org.ametys.core.ui.Callable;
024import org.ametys.core.ui.StaticClientSideElement;
025import org.ametys.plugins.contenttypeseditor.edition.SaveContentTypeComponent;
026
027/**
028 * Tool client side element for save a content type
029 */
030public class SaveContentTypeClientSideElement extends StaticClientSideElement
031{
032    /** The edit content type helper instance */
033    protected SaveContentTypeComponent _saveContentTypeHelper;
034
035    @Override
036    public void service(ServiceManager manager) throws ServiceException
037    {
038        super.service(manager);
039        _saveContentTypeHelper = (SaveContentTypeComponent) manager.lookup(SaveContentTypeComponent.ROLE);
040    }
041
042    /**
043     * Save a content type
044     * @param contentTypeInfos all information about the content type to save
045     * @return True if the content type was successfully saved
046     */
047    @Callable(right = "CMS_Rights_EditContentType", context = "/cms")
048    public boolean saveContentType(Map<String, Object> contentTypeInfos)
049    {
050        return _saveContentTypeHelper.saveContentType(contentTypeInfos);
051    }
052}