001/* 002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * eugen 016 */ 017package org.nuxeo.ecm.webapp.localconfiguration.search; 018 019import static org.nuxeo.ecm.webapp.localconfiguration.search.SearchLocalConfigurationConstants.DEFAULT_ADVANCED_SEARCH_VIEW; 020import static org.nuxeo.ecm.webapp.localconfiguration.search.SearchLocalConfigurationConstants.FIELD_ADVANCED_SEARCH_VIEW; 021 022import org.apache.commons.logging.Log; 023import org.apache.commons.logging.LogFactory; 024import org.nuxeo.ecm.core.api.DocumentModel; 025import org.nuxeo.ecm.core.api.DocumentRef; 026import org.nuxeo.ecm.core.api.PropertyException; 027import org.nuxeo.ecm.core.api.localconfiguration.AbstractLocalConfiguration; 028 029/** 030 * @author <a href="mailto:ei@nuxeo.com">Eugen Ionica</a> 031 */ 032public class SearchLocalConfigurationAdapter extends AbstractLocalConfiguration<SearchLocalConfiguration> implements 033 SearchLocalConfiguration { 034 035 private static final Log log = LogFactory.getLog(SearchLocalConfigurationAdapter.class); 036 037 DocumentModel doc; 038 039 public SearchLocalConfigurationAdapter(DocumentModel doc) { 040 super(); 041 this.doc = doc; 042 } 043 044 @Override 045 public DocumentRef getDocumentRef() { 046 return doc.getRef(); 047 } 048 049 @Override 050 public boolean canMerge() { 051 return false; 052 } 053 054 @Override 055 public SearchLocalConfiguration merge(SearchLocalConfiguration other) { 056 return null; 057 } 058 059 @Override 060 public String getAdvancedSearchView() { 061 String value = DEFAULT_ADVANCED_SEARCH_VIEW; 062 try { 063 value = (String) doc.getPropertyValue(FIELD_ADVANCED_SEARCH_VIEW); 064 } catch (PropertyException e) { 065 log.debug("Unable to retrieve configured advanced search content view for " + doc.getPathAsString(), e); 066 } 067 return value; 068 } 069 070}