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.util.Collection; 019import java.util.Date; 020import java.util.Locale; 021import java.util.Map; 022 023import org.xml.sax.ContentHandler; 024import org.xml.sax.SAXException; 025 026import org.ametys.cms.content.references.OutgoingReferences; 027import org.ametys.core.user.UserIdentity; 028import org.ametys.plugins.explorer.resources.ResourceCollection; 029import org.ametys.plugins.repository.AmetysRepositoryException; 030import org.ametys.plugins.repository.ModifiableACLAmetysObject; 031import org.ametys.plugins.repository.data.UnknownDataException; 032import org.ametys.plugins.repository.data.ametysobject.ModelAwareDataAwareAmetysObject; 033import org.ametys.plugins.repository.dublincore.DublinCoreAwareAmetysObject; 034import org.ametys.plugins.repository.metadata.MetadataAwareAmetysObject; 035import org.ametys.runtime.model.View; 036 037/** 038 * Content abstraction defined by the following properties: 039 * <dl> 040 * <dt>type 041 * <dd>the content type (can only be set on creation) 042 * <dt>language 043 * <dd>the language (can only be set on creation) 044 * <dt>title 045 * <dd>the title 046 * <dt>creator 047 * <dd>the login of the creator 048 * <dt>creationDate 049 * <dd>the date when the content was created 050 * <dt>lastContributor 051 * <dd>the login of the last contributor 052 * <dt>lastModified 053 * <dd>the date when the last modification takes place 054 * </dl> 055 */ 056public interface Content extends ModelAwareDataAwareAmetysObject, MetadataAwareAmetysObject, DublinCoreAwareAmetysObject, TagAwareAmetysObject, ModifiableACLAmetysObject 057{ 058 /** Constants for title attribute */ 059 public static final String ATTRIBUTE_TITLE = "title"; 060 061 /** 062 * Constants for title Metadata 063 * Use ATTRIBUTE_TITLE 064 */ 065 @Deprecated 066 public static final String METADATA_TITLE = "title"; 067 068 /** 069 * Retrieves the type identifiers of this content. 070 * @return the type identifiers of this content. 071 * @throws AmetysRepositoryException if an error occurs. 072 */ 073 public String[] getTypes() throws AmetysRepositoryException; 074 075 /** 076 * Retrieves the mixin type identifiers of this content. 077 * @return the mixin type identifiers of this content. 078 * @throws AmetysRepositoryException if an error occurs. 079 */ 080 public String[] getMixinTypes() throws AmetysRepositoryException; 081 082 /** 083 * Retrieves the language of this content.<br> 084 * @return the language of this content or <code>null</code> if the content is a multilingual content 085 * @throws AmetysRepositoryException if an error occurs. 086 */ 087 public String getLanguage() throws AmetysRepositoryException; 088 089 /** 090 * Retrieves the title for the given locale. If the locale is null or does not exist, the first locale will be used. 091 * @param locale The locale. Can be null if the content is not a multilingual content or to get the title in the default locale. 092 * @return the title. 093 * @throws UnknownDataException if this property does not exist. 094 * @throws AmetysRepositoryException if an error occurs. 095 */ 096 public String getTitle(Locale locale) throws UnknownDataException, AmetysRepositoryException; 097 098 /** 099 * Retrieves the title. 100 * This method is same as {@link #getTitle(Locale)} with a null locale. 101 * Use this method only if you are manipulating no-multilingual content. If not sure, use {@link #getTitle(Locale)} instead. 102 * @return the title. 103 * @throws UnknownDataException if this property does not exist. 104 * @throws AmetysRepositoryException if an error occurs. 105 */ 106 public String getTitle() throws UnknownDataException, AmetysRepositoryException; 107 108 /** 109 * Retrieves the login of the creator. 110 * @return the login of the creator. 111 * @throws UnknownDataException if this property does not exist. 112 * @throws AmetysRepositoryException if an error occurs. 113 */ 114 public UserIdentity getCreator() throws UnknownDataException, AmetysRepositoryException; 115 116 /** 117 * Retrieves the creation date. 118 * @return the creation date. 119 * @throws UnknownDataException if this property does not exist. 120 * @throws AmetysRepositoryException if an error occurs. 121 */ 122 public Date getCreationDate() throws UnknownDataException, AmetysRepositoryException; 123 124 /** 125 * Retrieves the login of the last contributor. 126 * @return the login of the last contributor. 127 * @throws UnknownDataException if this property does not exist. 128 * @throws AmetysRepositoryException if an error occurs. 129 */ 130 public UserIdentity getLastContributor() throws UnknownDataException, AmetysRepositoryException; 131 132 /** 133 * Retrieves the last modification date. 134 * @return the last modification date. 135 * @throws UnknownDataException if this property does not exist. 136 * @throws AmetysRepositoryException if an error occurs. 137 */ 138 public Date getLastModified() throws UnknownDataException, AmetysRepositoryException; 139 140 /** 141 * Retrieves the first validation date 142 * @return the first validation date 143 * @throws UnknownDataException if this property does not exist. 144 * @throws AmetysRepositoryException if an error occurs. 145 */ 146 public Date getFirstValidationDate() throws UnknownDataException, AmetysRepositoryException; 147 148 /** 149 * Retrieves the last validation date 150 * @return the last validation date 151 * @throws UnknownDataException if this property does not exist. 152 * @throws AmetysRepositoryException if an error occurs. 153 */ 154 public Date getLastValidationDate() throws UnknownDataException, AmetysRepositoryException; 155 156 /** 157 * Retrieves the last validation date resulting from a major modification. At least this is the first validation date 158 * @return the last validation date resulting from a major modification 159 * @throws UnknownDataException if this property does not exist. 160 * @throws AmetysRepositoryException if an error occurs. 161 */ 162 public Date getLastMajorValidationDate () throws UnknownDataException, AmetysRepositoryException; 163 164 /** 165 * Returns all Contents referencing this Content (as a metadata). 166 * @return all Contents referencing this Content. 167 * @throws AmetysRepositoryException if an error occurs. 168 */ 169 public Collection<Content> getReferencingContents() throws AmetysRepositoryException; 170 171 /** 172 * Returns <code>true</code> if there is at least one Content referencing this Content (as a metadata). 173 * @return <code>true</code> if there is at least one Content referencing this Content. 174 * @throws AmetysRepositoryException if an error occurs. 175 */ 176 public boolean hasReferencingContents() throws AmetysRepositoryException; 177 178 /** 179 * Get the stored outgoing references of the content. This references can be used for different purposes, such as testing link consistency for example. 180 * @return A non null map of outgoing references grouped by metadata (key are metadata path) 181 * @throws AmetysRepositoryException if an error occurs. 182 */ 183 public Map<String, OutgoingReferences> getOutgoingReferences() throws AmetysRepositoryException; 184 185 /** 186 * Retrieves the attachments root node 187 * @return The attachments root node, or null if the content is working on 188 * an (unmodifiable) old version and the attachments root is missing. 189 * @throws AmetysRepositoryException if an error occurs. 190 */ 191 public ResourceCollection getRootAttachments() throws AmetysRepositoryException; 192 193 /** 194 * Generates SAX events representing this Content. 195 * @param contentHandler the {@link ContentHandler} that will receive the SAX events. 196 * @param locale the {@link Locale} to use for eg. multilingual attributes. 197 * @param view the associated View, or null to generate SAX events for all attributes from the model. 198 * @param saxWorkflowStep if true, also generates SAX events for the current workflow step. 199 * @throws SAXException if an error occurs during the SAX events generation. 200 */ 201 public void toSAX(ContentHandler contentHandler, Locale locale, View view, boolean saxWorkflowStep) throws SAXException; 202}