2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.restconf.nb.rfc8040.rests.utils;
11 import javax.ws.rs.core.Response;
12 import javax.ws.rs.core.Response.ResponseBuilder;
13 import javax.ws.rs.core.Response.Status;
14 import org.opendaylight.yangtools.concepts.Builder;
16 final class ResponseFactory extends FutureDataFactory<Void> implements Builder<Response> {
18 private ResponseBuilder responseBuilder;
20 ResponseFactory(final Status status) {
21 this.responseBuilder = Response.status(status);
24 ResponseFactory location(final URI location) {
25 responseBuilder.location(location);
30 public Response build() {
31 if (getFailureStatus()) {
32 responseBuilder = responseBuilder.status(Response.Status.INTERNAL_SERVER_ERROR);
34 return this.responseBuilder.build();