001/* 002 * Copyright 2021 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.web.duplicate; 017 018import java.util.List; 019import java.util.Set; 020 021import org.ametys.cms.duplicate.contents.DuplicateContentTypeConfiguration; 022import org.ametys.cms.repository.Content; 023import org.ametys.cms.search.query.Query; 024import org.ametys.web.repository.content.WebContent; 025import org.ametys.web.repository.site.Site; 026import org.ametys.web.search.query.SiteQuery; 027 028/** 029 * Component able to detect duplicates (and near duplicates) for a given content. 030 */ 031public class DuplicateContentsManager extends org.ametys.cms.duplicate.contents.DuplicateContentsManager 032{ 033 @Override 034 protected List<Query> _getDuplicatesQueries(Content content, Set<DuplicateContentTypeConfiguration> duplicateContentTypeConfigurations, boolean nearDuplicates, String[] contentTypes) 035 { 036 List<Query> queries = super._getDuplicatesQueries(content, duplicateContentTypeConfigurations, nearDuplicates, contentTypes); 037 if (content instanceof WebContent) 038 { 039 Site site = ((WebContent) content).getSite(); 040 queries.add(new SiteQuery(site.getName())); 041 } 042 return queries; 043 } 044}