Merge "Fix build errors in autorelease full clean build"
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / java / org / eclipse / winery / repository / resources / entitytypes / artifacttypes / ArtifactTypeResource.java
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
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.repository.resources.entitytypes.artifacttypes;
13
14 import java.util.SortedSet;
15
16 import javax.ws.rs.GET;
17 import javax.ws.rs.PUT;
18 import javax.ws.rs.Path;
19 import javax.ws.rs.core.Response;
20 import javax.xml.namespace.QName;
21
22 import org.eclipse.winery.common.constants.Namespaces;
23 import org.eclipse.winery.common.ids.definitions.ArtifactTemplateId;
24 import org.eclipse.winery.common.ids.definitions.ArtifactTypeId;
25 import org.eclipse.winery.model.tosca.TArtifactType;
26 import org.eclipse.winery.model.tosca.TExtensibleElements;
27 import org.eclipse.winery.repository.backend.BackendUtils;
28 import org.eclipse.winery.repository.datatypes.select2.Select2OptGroup;
29 import org.eclipse.winery.repository.resources.EntityTypeResource;
30
31 public class ArtifactTypeResource extends EntityTypeResource {
32         
33         public ArtifactTypeResource(ArtifactTypeId id) {
34                 super(id);
35         }
36         
37         
38         private final QName qnameFileExtension = new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "fileExtension");
39         
40         
41         /**
42          * @return the file extension associated with this artifact type. May be
43          *         null
44          */
45         @GET
46         @Path("/fileextension")
47         public String getAssociatedFileExtension() {
48                 return this.getDefinitions().getOtherAttributes().get(this.qnameFileExtension);
49         }
50         
51         @PUT
52         @Path("/fileextension")
53         public Response setAssociatedFileExtension(String fileExtension) {
54                 this.getDefinitions().getOtherAttributes().put(this.qnameFileExtension, fileExtension);
55                 return BackendUtils.persist(this);
56         }
57         
58         @Override
59         protected TExtensibleElements createNewElement() {
60                 return new TArtifactType();
61         }
62         
63         @Override
64         public SortedSet<Select2OptGroup> getListOfAllInstances() {
65                 return this.getListOfAllInstances(ArtifactTemplateId.class);
66         }
67 }