5a909dc731a7d7e44339337a4aeb9c488f15206a
[aaa.git] / aaa-idmlight / src / main / java / org / opendaylight / aaa / idm / model / IDMError.java
1 /*
2  * Copyright (c) 2014, 2015 Hewlett-Packard Development Company, L.P. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.aaa.idm.model;
10
11 /**
12  *
13  * @author peter.mellquist@hp.com
14  *
15  */
16
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19 import javax.xml.bind.annotation.XmlRootElement;
20 import javax.ws.rs.core.Response;
21
22 @XmlRootElement(name = "idmerror")
23 public class IDMError{
24    private static Logger logger = LoggerFactory.getLogger(IDMError.class);
25
26    private String message;
27    private String details;
28    private int code=500;
29
30    public IDMError() {
31    };
32
33    public IDMError(int statusCode, String msg, String msgDetails) {
34       code=statusCode;
35       message=msg;
36       details=msgDetails;
37    }
38
39    public String getMessage() {
40       return message;
41    }
42
43    public void setMessage(String msg) {
44       this.message=msg;
45    }
46
47    public String getDetails() {
48       return details;
49    }
50
51    public void setDetails(String details) {
52       this.details=details;
53    }
54
55    public Response response() {
56       logger.error("error: " + this.message + " details: " + this.details + " status: " + code);
57       return Response.status(this.code).entity(this).build();
58    }
59
60 }