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.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.mdsal.common.api.CommitInfo;
17 final class ResponseFactory extends FutureDataFactory<CommitInfo> {
18 private ResponseBuilder responseBuilder;
23 ResponseFactory(final Status status) {
24 responseBuilder = Response.status(status);
27 ResponseFactory status(final Status status) {
28 responseBuilder = Response.status(status);
32 ResponseFactory location(final URI location) {
33 responseBuilder.location(location);
37 public @NonNull Response build() {
38 if (getFailureStatus()) {
39 responseBuilder = responseBuilder.status(Response.Status.INTERNAL_SERVER_ERROR);
41 return responseBuilder.build();