1 /* 2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.properties.spi.config.transfer; 17 18 import de.smartics.exceptions.i18n.message.MessageParam; 19 import de.smartics.properties.api.core.app.AbstractBaseMessageBean; 20 import de.smartics.properties.api.core.domain.PropertiesContext; 21 import de.smartics.properties.resource.domain.ArtifactRef; 22 23 /** 24 * Provides information to signal that there is no {@code definition.xml} file 25 * found or the URL to the file cannot be constructed. 26 */ 27 public class DefinitionXmlMessageBean extends AbstractBaseMessageBean 28 implements TransferMessageBean 29 { 30 // ********************************* Fields ********************************* 31 32 // --- constants ------------------------------------------------------------ 33 34 /** 35 * The class version identifier. 36 * <p> 37 * The value of this constant is {@value}. 38 * </p> 39 */ 40 private static final long serialVersionUID = 1L; 41 42 // --- members -------------------------------------------------------------- 43 44 /** 45 * The reference to the artifact that lacks the {@code definition.xml}. 46 * 47 * @serial 48 */ 49 @MessageParam 50 private final ArtifactRef artifact; // NOPMD 51 52 /** 53 * The {@code definition.xml} that has not been found in the given archive. 54 * 55 * @serial 56 */ 57 @MessageParam 58 private final String definitionXml = PropertiesContext.DEFINITION_FILE; 59 60 // ****************************** Initializer ******************************* 61 62 // ****************************** Constructors ****************************** 63 64 /** 65 * Constructor without cause. 66 * 67 * @param code the error or exception code of the exception. 68 * @param artifact the reference to the artifact that lacks the 69 * {@code definition.xml}. 70 */ 71 public DefinitionXmlMessageBean(final TransferCode code, 72 final ArtifactRef artifact) 73 { 74 this(code, null, artifact); 75 } 76 77 /** 78 * Default constructor. 79 * 80 * @param code the error or exception code of the exception. 81 * @param cause the cause to the problem. 82 * @param artifact the reference to the artifact that lacks the 83 * {@code definition.xml}. 84 */ 85 public DefinitionXmlMessageBean(final TransferCode code, 86 final Throwable cause, final ArtifactRef artifact) 87 { 88 super(code, cause); 89 this.artifact = artifact; 90 } 91 92 // ****************************** Inner Classes ***************************** 93 94 // ********************************* Methods ******************************** 95 96 // --- init ----------------------------------------------------------------- 97 98 // --- factory -------------------------------------------------------------- 99 100 /** 101 * Creates a message bean with code {@link TransferCode#NO_DEFINITION_XML}. 102 * 103 * @param cause the cause to the problem. 104 * @param artifact the reference to the artifact that lacks the 105 * {@code definition.xml}. 106 * @return the created message bean. 107 */ 108 public static TransferMessageBean missingDefinition(final Throwable cause, 109 final ArtifactRef artifact) 110 { 111 return new DefinitionXmlMessageBean(TransferCode.NO_DEFINITION_XML, 112 cause, artifact); 113 } 114 115 /** 116 * Creates a message bean with code 117 * {@link TransferCode#MALFORMED_URL_TO_DEFINITION_XML}. 118 * 119 * @param cause the cause to the problem. 120 * @param artifact the reference to the artifact the URL cannot be constructed 121 * to. 122 * @return the created message bean. 123 */ 124 public static TransferMessageBean malformedUrl(final Throwable cause, 125 final ArtifactRef artifact) 126 { 127 return new DefinitionXmlMessageBean( 128 TransferCode.MALFORMED_URL_TO_DEFINITION_XML, cause, artifact); 129 } 130 131 // --- get&set -------------------------------------------------------------- 132 133 // --- business ------------------------------------------------------------- 134 135 // --- object basics -------------------------------------------------------- 136 137 }