b18341f5cf131935f16e160d6f32ed8749061562
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / java / org / eclipse / winery / repository / resources / servicetemplates / boundarydefinitions / policies / PoliciesResource.java
1 /*******************************************************************************
2  * Copyright (c) 2014 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
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.repository.resources.servicetemplates.boundarydefinitions.policies;
13
14 import java.util.List;
15
16 import javax.ws.rs.PUT;
17 import javax.ws.rs.core.Response;
18
19 import org.eclipse.winery.model.tosca.TPolicy;
20 import org.eclipse.winery.repository.backend.BackendUtils;
21 import org.eclipse.winery.repository.resources._support.IPersistable;
22 import org.eclipse.winery.repository.resources._support.collections.withoutid.EntityWithoutIdCollectionResource;
23
24 import com.sun.jersey.api.view.Viewable;
25
26 public class PoliciesResource extends EntityWithoutIdCollectionResource<PolicyResource, TPolicy> {
27         
28         public PoliciesResource(List<TPolicy> list, IPersistable res) {
29                 super(PolicyResource.class, TPolicy.class, list, res);
30         }
31         
32         @Override
33         public Viewable getHTML() {
34                 throw new IllegalStateException("Not required: boundarydefinitions.jsp also includes the content of the Policy tab.");
35         }
36         
37         @PUT
38         public Response replaceAll(List<TPolicy> newList) {
39                 this.list.clear();
40                 for (TPolicy policy : newList) {
41                         this.list.add(policy);
42                 }
43                 return BackendUtils.persist(this.res);
44         }
45         
46 }