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.resources._support.collections;
14 import javax.ws.rs.core.Response;
16 import org.eclipse.winery.repository.backend.BackendUtils;
17 import org.eclipse.winery.repository.resources._support.IPersistable;
19 public class CollectionsHelper {
21 private CollectionsHelper() {
27 * @param resource the resource to be persisted
28 * @param idDetermination the object to use to determine the id of the
30 * @param entity the entity that was persisted. Used to determine the id
31 * @return the new id id of the resource
33 public static <X> Response persist(IPersistable resource, IIdDetermination<X> idDetermination, X entity) {
34 Response res = BackendUtils.persist(resource);
35 if (res.getStatus() == 204) {
36 String id = idDetermination.getId(entity);
37 res = Response.ok(id).build();