1package org.apache.archiva.redback.rest.api.model;
2/*3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing,14 * software distributed under the License is distributed on an15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY16 * KIND, either express or implied. See the License for the17 * specific language governing permissions and limitations18 * under the License.19 */2021import org.apache.commons.lang.StringUtils;
22import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
2324import javax.xml.bind.annotation.XmlRootElement;
25import java.io.Serializable;
26import java.util.ArrayList;
27import java.util.List;
2829/**30 * @author Olivier Lamy31 * @since 1.432 */33 @XmlRootElement( name = "redbackRestError" )
34publicclassRedbackRestError35implements Serializable
36 {
3738private List<ErrorMessage> errorMessages = new ArrayList<ErrorMessage>( 1 );
3940publicRedbackRestError()
41 {
42// no op43 }
4445publicRedbackRestError( RedbackServiceException e )
46 {
47 errorMessages.addAll( e.getErrorMessages() );
48if ( e.getErrorMessages().isEmpty() && StringUtils.isNotEmpty( e.getMessage() ) )
49 {
50 errorMessages.add( new ErrorMessage( e.getMessage(), null ) );
51 }
52 }
535455public List<ErrorMessage> getErrorMessages()
56 {
57return errorMessages;
58 }
5960publicvoid setErrorMessages( List<ErrorMessage> errorMessages )
61 {
62this.errorMessages = errorMessages;
63 }
6465publicvoid addErrorMessage( ErrorMessage errorMessage )
66 {
67this.errorMessages.add( errorMessage );
68 }
69 }