001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.ade.publish;
029
030import org.opencms.ade.publish.shared.CmsProjectBean;
031import org.opencms.ade.publish.shared.CmsPublishOptions;
032import org.opencms.file.CmsObject;
033import org.opencms.file.CmsResource;
034import org.opencms.main.CmsException;
035import org.opencms.main.CmsLog;
036import org.opencms.main.OpenCms;
037import org.opencms.util.CmsUUID;
038
039import java.util.List;
040import java.util.Locale;
041import java.util.Map;
042
043import org.apache.commons.logging.Log;
044
045import com.google.common.collect.Lists;
046
047/**
048 * Virtual project for the "My changes" mode in the publish dialog.<p>
049 */
050public class CmsMyChangesProject implements I_CmsVirtualProject {
051
052    /** The project id. */
053    public static final CmsUUID ID = CmsUUID.getNullUUID();
054
055    /** The logger for this class. */
056    private static final Log LOG = CmsLog.getLog(CmsMyChangesProject.class);
057
058    /**
059     * @see org.opencms.ade.publish.I_CmsVirtualProject#getProjectBean(org.opencms.file.CmsObject, java.util.Map)
060     */
061    public CmsProjectBean getProjectBean(CmsObject cms, Map<String, String> params) {
062
063        Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
064        String title = Messages.get().getBundle(locale).key(Messages.GUI_MYCHANGES_PROJECT_0);
065        CmsProjectBean bean = new CmsProjectBean(ID, 0, title, title);
066        bean.setRank(200);
067        bean.setDefaultGroupName("");
068        return bean;
069    }
070
071    /**
072     * @see org.opencms.ade.publish.I_CmsVirtualProject#getProjectId()
073     */
074    public CmsUUID getProjectId() {
075
076        return ID;
077    }
078
079    /**
080     * @see org.opencms.ade.publish.I_CmsVirtualProject#getRelatedResourceProvider(org.opencms.file.CmsObject, org.opencms.ade.publish.shared.CmsPublishOptions)
081     */
082    public I_CmsPublishRelatedResourceProvider getRelatedResourceProvider(
083        CmsObject cmsObject,
084        CmsPublishOptions options) {
085
086        return CmsDummyRelatedResourceProvider.INSTANCE;
087    }
088
089    /**
090     * @see org.opencms.ade.publish.I_CmsVirtualProject#getResources(org.opencms.file.CmsObject, java.util.Map, java.lang.String)
091     */
092    public List<CmsResource> getResources(CmsObject cms, Map<String, String> params, String workflowId) {
093
094        try {
095            return Lists.newArrayList(OpenCms.getPublishManager().getUsersPubList(cms));
096        } catch (CmsException e) {
097            LOG.error(e.getLocalizedMessage(), e);
098            return Lists.newArrayList();
099        }
100    }
101
102    /**
103     * @see org.opencms.ade.publish.I_CmsVirtualProject#isAutoSelectable()
104     */
105    public boolean isAutoSelectable() {
106
107        return true;
108    }
109
110}