001/* 002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. 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 * 016 * Contributors: 017 * Bogdan Stefanescu 018 * Florent Guillaume 019 */ 020package org.nuxeo.ecm.core.schema; 021 022import org.nuxeo.ecm.core.schema.types.CompositeType; 023 024import java.util.Collection; 025import java.util.Set; 026 027/** 028 * Document types are composite types made of several schemas. 029 * <p> 030 * Sample document types are Workspace, Section, Domain,... The list of builtin document type is visible at 031 * NXCore/OSGI-INF/CoreExtensions.xml. 032 */ 033public interface DocumentType extends CompositeType { 034 035 /** 036 * Gets the prefetch info, or null if no prefetch is defined. 037 * <p> 038 * If the prefetch info is not null, the caller should use it when instantiating a document to preload the fields 039 * defined by the prefetch info. 040 * <p> 041 * If no prefetch is specified by the document type, the caller is free to use a default prefetch info or no 042 * prefetch at all. 043 * 044 * @return the prefetch info or null 045 */ 046 PrefetchInfo getPrefetchInfo(); 047 048 /** 049 * Tests whether this type describes a document (not a folder!) or not. 050 * 051 * @return true if the type describes a document folder, otherwise returns false 052 */ 053 boolean isFile(); 054 055 /** 056 * Tests whether this type describes a folder or not. 057 * 058 * @return true if the type describes a folder, otherwise returns false 059 */ 060 boolean isFolder(); 061 062 /** 063 * Tests whether this type describe an ordered folder or not. 064 * 065 * @return true if the type describes an ordered folder, otherwise returns false 066 */ 067 boolean isOrdered(); 068 069 /** 070 * Gets all the facets of this document type. 071 * <p> 072 * Facets inherited from parents are taken into account. 073 * 074 * @return the facets 075 */ 076 Set<String> getFacets(); 077 078 /** 079 * Returns {@code true} if this document type has the given {@code facetName} facet, {@code false otherwise}. 080 * 081 * @since 5.7 082 */ 083 boolean hasFacet(String facetName); 084 085 /** 086 * Returns the types of the children that can be created inside this type. 087 * 088 * @since 8.4 089 */ 090 Set<String> getSubtypes(); 091 092 /** 093 * Sets the types of the children that can be created inside the this type. 094 * 095 * @since 8.4 096 */ 097 void setSubtypes(Collection<String> subtypes); 098 099 /** 100 * Returns {@code true} if the given {@code subtype} type was explicitly allowed to be created inside this type. 101 * 102 * @since 8.4 103 */ 104 boolean hasSubtype(String subtype); 105 106 /** 107 * Returns the types of the children that cannot be created inside this type. 108 * 109 * @since 8.4 110 */ 111 Set<String> getForbiddenSubtypes(); 112 113 /** 114 * Sets the types of the children that cannot be created inside the this type. 115 * 116 * @since 8.4 117 */ 118 void setForbiddenSubtypes(Collection<String> subtypes); 119 120 /** 121 * Returns {@code true} if the given {@code subtype} type was forbidden from being created inside this type. 122 * 123 * @since 8.4 124 */ 125 boolean hasForbiddenSubtype(String subtype); 126 127 /** 128 * Returns the list of types that can effectively be created inside this type. 129 * Allowed types results from the exclusion of the forbidden subtypes from the subtypes. 130 * 131 * @since 8.4 132 */ 133 Set<String> getAllowedSubtypes(); 134 135 /** 136 * Returns {@code true} if the given {@code subtype} type can effectively be created inside this type. 137 * 138 * @since 8.4 139 */ 140 boolean hasAllowedSubtype(String subtype); 141 142}