001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 Echo Three, LLC 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 017package com.echothree.model.control.core.server.logic; 018 019import com.echothree.model.control.core.common.exception.UnknownFontStyleNameException; 020import com.echothree.model.control.core.common.exception.UnknownFontWeightNameException; 021import com.echothree.model.control.core.server.control.FontControl; 022import com.echothree.model.data.core.server.entity.FontStyle; 023import com.echothree.model.data.core.server.entity.FontWeight; 024import com.echothree.util.common.message.ExecutionErrors; 025import com.echothree.util.server.control.BaseLogic; 026import com.echothree.util.server.message.ExecutionErrorAccumulator; 027import javax.enterprise.context.ApplicationScoped; 028import javax.inject.Inject; 029 030@ApplicationScoped 031public class FontLogic 032 extends BaseLogic { 033 034 @Inject 035 protected FontControl fontControl; 036 037 protected FontLogic() { 038 super(); 039 } 040 041 public FontStyle getFontStyleByName(final ExecutionErrorAccumulator eea, final String fontStyleName) { 042 var fontStyle = fontControl.getFontStyleByName(fontStyleName); 043 044 if(fontStyle == null) { 045 handleExecutionError(UnknownFontStyleNameException.class, eea, ExecutionErrors.UnknownFontStyleName.name(), fontStyleName); 046 } 047 048 return fontStyle; 049 } 050 051 public FontWeight getFontWeightByName(final ExecutionErrorAccumulator eea, final String fontWeightName) { 052 var fontWeight = fontControl.getFontWeightByName(fontWeightName); 053 054 if(fontWeight == null) { 055 handleExecutionError(UnknownFontWeightNameException.class, eea, ExecutionErrors.UnknownFontWeightName.name(), fontWeightName); 056 } 057 058 return fontWeight; 059 } 060 061}