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.entitytemplates;
14 import javax.ws.rs.Consumes;
15 import javax.ws.rs.GET;
16 import javax.ws.rs.PUT;
17 import javax.ws.rs.Produces;
18 import javax.ws.rs.core.MediaType;
19 import javax.ws.rs.core.Response;
21 import org.eclipse.winery.model.tosca.TEntityTemplate;
22 import org.eclipse.winery.repository.backend.BackendUtils;
23 import org.eclipse.winery.repository.resources.AbstractComponentInstanceResource;
25 import com.sun.jersey.api.view.Viewable;
27 public class PropertiesResource {
29 private AbstractComponentInstanceResource res;
30 private TEntityTemplate template;
34 * @param template the template to store the definitions at
35 * @param res the resource to save after modifications
37 public PropertiesResource(TEntityTemplate template, AbstractComponentInstanceResource res) {
38 this.template = template;
43 * Currently, properties can only be updated as a whole XML fragment
45 * Getting/setting a fragment of properties is not possible yet
48 @Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
49 public Response setProperties(TEntityTemplate.Properties properties) {
50 this.getTemplate().setProperties(properties);
51 return BackendUtils.persist(this.res);
55 @Produces(MediaType.TEXT_HTML)
56 public Viewable getHTML() {
57 return new Viewable("/jsp/entitytemplates/properties.jsp", this);
60 /** data for the JSP **/
62 public TEntityTemplate getTemplate() {