1 /*******************************************************************************
2 * Copyright (c) 2012-2013 University of Stuttgart.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * Oliver Kopp - initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.winery.repository.backend;
16 import javax.ws.rs.core.Response;
17 import javax.ws.rs.core.Response.Status;
19 import org.eclipse.winery.common.ids.GenericId;
21 public class ResourceCreationResult {
23 private Status status = null;
24 private URI uri = null;
25 private GenericId id = null;
28 public ResourceCreationResult() {
31 public ResourceCreationResult(Status status) {
32 this.setStatus(status);
35 public ResourceCreationResult(Status status, URI uri, GenericId id) {
36 this.setStatus(status);
41 public Status getStatus() {
45 public void setStatus(Status status) {
53 public void setUri(URI uri) {
57 public GenericId getId() {
61 public void setId(GenericId id) {
65 public boolean isSuccess() {
66 return this.getStatus() == Status.CREATED;
70 * The possibly existing URI is used as location in Response.created
72 * @return a Response created based on the contained data
74 public Response getResponse() {
76 if (this.getUri() == null) {
77 res = Response.status(this.getStatus()).build();
79 assert (this.getStatus().equals(Status.CREATED));
80 res = Response.created(this.getUri()).build();