001/* 002 * (C) Copyright 2011-2016 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 * Nuxeo - initial API and implementation 018 */ 019package org.nuxeo.theme.localconfiguration; 020 021import org.nuxeo.ecm.core.api.DocumentModel; 022import org.nuxeo.ecm.core.api.DocumentRef; 023import org.nuxeo.ecm.core.api.PropertyException; 024import org.nuxeo.ecm.core.api.localconfiguration.AbstractLocalConfiguration; 025 026/** 027 * Default implementation of {@code LocalThemeConfig}. 028 * 029 * @author <a href="mailto:qlamerand@nuxeo.com">Quentin Lamerand</a> 030 */ 031public class LocalThemeConfigAdapter extends AbstractLocalConfiguration<LocalThemeConfig> implements LocalThemeConfig { 032 033 protected DocumentRef documentRef; 034 035 protected String theme; 036 037 protected String page; 038 039 protected String perspective; 040 041 protected String engine; 042 043 protected String mode; 044 045 protected String flavor; 046 047 public LocalThemeConfigAdapter(DocumentModel doc) { 048 documentRef = doc.getRef(); 049 try { 050 theme = (String) doc.getPropertyValue(LocalThemeConfigConstants.THEME_CONFIGURATION_THEME_PROPERTY); 051 page = (String) doc.getPropertyValue(LocalThemeConfigConstants.THEME_CONFIGURATION_PAGE_PROPERTY); 052 perspective = (String) doc.getPropertyValue( 053 LocalThemeConfigConstants.THEME_CONFIGURATION_PERSPECTIVE_PROPERTY); 054 engine = (String) doc.getPropertyValue(LocalThemeConfigConstants.THEME_CONFIGURATION_ENGINE_PROPERTY); 055 mode = (String) doc.getPropertyValue(LocalThemeConfigConstants.THEME_CONFIGURATION_MODE_PROPERTY); 056 flavor = (String) doc.getPropertyValue(LocalThemeConfigConstants.THEME_CONFIGURATION_FLAVOR_PROPERTY); 057 } catch (PropertyException e) { 058 } 059 } 060 061 @Override 062 public DocumentRef getDocumentRef() { 063 return documentRef; 064 } 065 066 @Override 067 public boolean canMerge() { 068 return false; 069 } 070 071 @Override 072 public LocalThemeConfig merge(LocalThemeConfig other) { 073 return this; 074 } 075 076 /** 077 * @since 5.5 078 */ 079 @Override 080 public String getFlavor() { 081 return flavor; 082 } 083 084}