001/* 002 * (C) Copyright 2011 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 * eugen 018 */ 019package org.nuxeo.ecm.webapp.localconfiguration.search; 020 021import static org.nuxeo.ecm.webapp.localconfiguration.search.SearchLocalConfigurationConstants.DEFAULT_ADVANCED_SEARCH_VIEW; 022import static org.nuxeo.ecm.webapp.localconfiguration.search.SearchLocalConfigurationConstants.FIELD_ADVANCED_SEARCH_VIEW; 023 024import org.apache.commons.logging.Log; 025import org.apache.commons.logging.LogFactory; 026import org.nuxeo.ecm.core.api.DocumentModel; 027import org.nuxeo.ecm.core.api.DocumentRef; 028import org.nuxeo.ecm.core.api.PropertyException; 029import org.nuxeo.ecm.core.api.localconfiguration.AbstractLocalConfiguration; 030 031/** 032 * @author <a href="mailto:[email protected]">Eugen Ionica</a> 033 */ 034public class SearchLocalConfigurationAdapter extends AbstractLocalConfiguration<SearchLocalConfiguration> implements 035 SearchLocalConfiguration { 036 037 private static final Log log = LogFactory.getLog(SearchLocalConfigurationAdapter.class); 038 039 DocumentModel doc; 040 041 public SearchLocalConfigurationAdapter(DocumentModel doc) { 042 super(); 043 this.doc = doc; 044 } 045 046 @Override 047 public DocumentRef getDocumentRef() { 048 return doc.getRef(); 049 } 050 051 @Override 052 public boolean canMerge() { 053 return false; 054 } 055 056 @Override 057 public SearchLocalConfiguration merge(SearchLocalConfiguration other) { 058 return null; 059 } 060 061 @Override 062 public String getAdvancedSearchView() { 063 String value = DEFAULT_ADVANCED_SEARCH_VIEW; 064 try { 065 value = (String) doc.getPropertyValue(FIELD_ADVANCED_SEARCH_VIEW); 066 } catch (PropertyException e) { 067 log.debug("Unable to retrieve configured advanced search content view for " + doc.getPathAsString(), e); 068 } 069 return value; 070 } 071 072}