001/*
002 *  Copyright 2010 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.cms.repository;
017
018import java.time.ZonedDateTime;
019import java.util.Optional;
020
021import org.ametys.cms.data.holder.ModifiableIndexableDataHolder;
022import org.ametys.cms.data.holder.group.ModifiableIndexableComposite;
023import org.ametys.plugins.repository.AmetysRepositoryException;
024import org.ametys.plugins.repository.data.holder.ModifiableDataHolder;
025import org.ametys.plugins.workflow.repository.WorkflowAwareAmetysObject;
026import org.ametys.runtime.model.exception.BadDataPathCardinalityException;
027import org.ametys.runtime.model.exception.BadItemTypeException;
028import org.ametys.runtime.model.exception.UndefinedItemPathException;
029
030/**
031 * {@link Content} abstraction defined by the following additional property:
032 * <dl>
033 *   <dt>workflowId
034 *   <dd>the id of the workflow instance associated with the content
035 * </dl>
036 */
037public interface WorkflowAwareContent extends Content, WorkflowAwareAmetysObject
038{
039    /**
040     * Retrieves the date at which the content was proposed for validation,
041     * i.e. put in a workflow step in which it's awaiting validation.
042     * @return the date at which the content was proposed for validation.
043     * @throws AmetysRepositoryException if an error occurs.
044     */
045    default ZonedDateTime getProposalDate() throws AmetysRepositoryException
046    {
047        return WorkflowAwareContentHelper.getProposalDate(this);
048    }
049    
050    /**
051     * Set the date at which the content was proposed for validation, i.e.
052     * put in a workflow step in which it's awaiting validation.
053     * @param proposalDate the date at which the content was proposed for validation, or null to remove it.
054     * @throws AmetysRepositoryException if an error occurs.
055     */
056    default void setProposalDate(ZonedDateTime proposalDate) throws AmetysRepositoryException
057    {
058        WorkflowAwareContentHelper.setProposalDate(this, proposalDate);
059    }
060    
061    default ModifiableDataHolder getWorkflowMetadataHolder()
062    {
063        return getInternalDataHolder();
064    }
065    
066    @Override
067    public ModifiableIndexableComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException;
068    
069    @Override
070    public Optional<? extends ModifiableIndexableDataHolder> getParentDataHolder();
071    
072    @Override
073    public ModifiableIndexableDataHolder getRootDataHolder();
074}
075