001/* 002 * (C) Copyright 2013 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 * Wojciech Sulejman 018 * Vladimir Pasquier <vpasquier@nuxeo.com> 019 */ 020 021package org.nuxeo.ecm.platform.signature.core.sign; 022 023import org.nuxeo.common.xmap.annotation.XNode; 024import org.nuxeo.common.xmap.annotation.XObject; 025import org.nuxeo.ecm.platform.signature.api.sign.SignatureAppearanceFactory; 026 027/** 028 * Provides default values for signing services. 029 * 030 * @author <a href="mailto:ws@nuxeo.com">Wojciech Sulejman</a> 031 */ 032@XObject("configuration") 033public class SignatureDescriptor { 034 035 @XNode("@id") 036 protected String id; 037 038 @XNode("reason") 039 protected String reason; 040 041 @XNode("layout") 042 protected SignatureLayout signatureLayout; 043 044 @XNode("appearanceFactory") 045 protected SignatureAppearance signatureAppearance = null; 046 047 @XObject("appearanceFactory") 048 public static class SignatureAppearance { 049 @XNode("@class") 050 protected Class<? extends SignatureAppearanceFactory> appearanceClass; 051 052 public Class<? extends SignatureAppearanceFactory> getAppearanceClass() { 053 return appearanceClass; 054 } 055 } 056 057 /** 058 * @since 5.8 Definition of the layout applied on signatures. 059 */ 060 @XObject("layout") 061 public static class SignatureLayout implements org.nuxeo.ecm.platform.signature.api.sign.SignatureLayout { 062 063 @XNode("@lines") 064 protected Integer lines = 5; 065 066 @XNode("@columns") 067 protected Integer columns = 3; 068 069 @XNode("@startLine") 070 protected Integer startLine = 1; 071 072 @XNode("@startColumn") 073 protected Integer startColumn = 1; 074 075 @XNode("@textSize") 076 protected Integer textSize = 9; 077 078 @Override 079 public Integer getLines() { 080 return lines; 081 } 082 083 @Override 084 public Integer getColumns() { 085 return columns; 086 } 087 088 @Override 089 public Integer getStartLine() { 090 return startLine; 091 } 092 093 @Override 094 public Integer getStartColumn() { 095 return startColumn; 096 } 097 098 @Override 099 public Integer getTextSize() { 100 return textSize; 101 } 102 } 103 104 public SignatureLayout getSignatureLayout() { 105 return signatureLayout; 106 } 107 108 public String getReason() { 109 return reason; 110 } 111 112 public void setReason(String reason) { 113 this.reason = reason; 114 } 115 116 public SignatureAppearanceFactory getAppearanceFatory() throws InstantiationException, IllegalAccessException { 117 Class<? extends SignatureAppearanceFactory> appearanceClass = null; 118 if (signatureAppearance != null) { 119 appearanceClass = signatureAppearance.getAppearanceClass(); 120 } 121 if (appearanceClass == null) { 122 return new DefaultSignatureAppearanceFactory(); 123 } 124 return appearanceClass.newInstance(); 125 } 126 127 public String getId() { 128 return id; 129 } 130 131 private boolean remove; 132 133 @XNode("removeExtension") 134 protected void setRemoveExtension(boolean remove) { 135 this.remove = remove; 136 } 137 138 public boolean getRemoveExtension() { 139 return remove; 140 } 141 142}