Add winery source code
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / java / org / eclipse / winery / repository / resources / imports / ImportsResource.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.imports;
13
14 import javax.ws.rs.Path;
15 import javax.ws.rs.PathParam;
16
17 import org.eclipse.winery.common.Util;
18 import org.eclipse.winery.repository.resources.AbstractComponentsResource;
19 import org.eclipse.winery.repository.resources.imports.genericimports.GenericImportsResource;
20 import org.eclipse.winery.repository.resources.imports.xsdimports.XSDImportsResource;
21
22 /**
23  * The specification does not nest the sequence of import elements in an imports
24  * container. We introduce such a container to be consistent with the other
25  * resource naming
26  */
27 public class ImportsResource {
28         
29         @Path("{id}/")
30         public AbstractComponentsResource getXSDsResource(@PathParam("id") String id) {
31                 // once: decoding for browser locations
32                 id = Util.URLdecode(id);
33                 // once again: real URI
34                 id = Util.URLdecode(id);
35                 if (id.equals("http://www.w3.org/2001/XMLSchema")) {
36                         // Models http://www.w3.org/2001/XMLSchema. We do not use xsd instead of the
37                         // encoded namespace, because this induces special cases at many places
38                         return new XSDImportsResource();
39                 } else {
40                         return new GenericImportsResource(id);
41                 }
42         }
43         
44 }