Replaced all tabs with spaces in java and pom.xml
[so.git] / common / src / main / java / org / onap / so / client / aai / entities / uri / AAIUriFactory.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.client.aai.entities.uri;
22
23 import java.net.URI;
24 import org.onap.so.client.aai.AAIObjectPlurals;
25 import org.onap.so.client.aai.AAIObjectType;
26
27
28 public class AAIUriFactory {
29
30     /**
31      * values are filled into the URI template specified in {@link AAIObjectType} in order <br>
32      * There are two special lookups performed on certain types when a single value is specified: <br>
33      * Service Instance and AllottedResources <br>
34      * These can be retrieved without all their required keys but an HTTP call is required to do so
35      * 
36      * @param type
37      * @param values
38      * @return
39      */
40     public static AAIResourceUri createResourceUri(AAIObjectType type, Object... values) {
41         if (AAIObjectType.SERVICE_INSTANCE.equals(type)) {
42             return new ServiceInstanceUri(values);
43         } else if (AAIObjectType.ALLOTTED_RESOURCE.equals(type)) {
44             return new AllottedResourceLookupUri(values);
45         } else {
46             return new AAISimpleUri(type, values);
47         }
48     }
49
50     public static AAIResourceUri createNodesUri(AAIObjectType type, Object... values) {
51         return new NodesUri(type, values);
52
53     }
54
55     public static AAIResourceUri createNodesUri(AAIObjectPlurals type) {
56         return new NodesUri(type);
57
58     }
59
60     /**
61      * This method should only be used to wrap a URI retrieved from A&AI contained within an object response
62      * 
63      * @param type
64      * @param uri
65      * @return
66      */
67     public static AAIResourceUri createResourceFromExistingURI(AAIObjectType type, URI uri) {
68         return new AAISimpleUri(type, uri);
69     }
70
71
72     /**
73      * creates an AAIResourceUri from a parentUri
74      * 
75      * @param parentUri
76      * @param childType
77      * @param childValues
78      * @return
79      */
80     public static AAIResourceUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectType childType,
81             Object... childValues) {
82
83         return new AAISimpleUri(parentUri, childType, childValues);
84     }
85
86     public static AAIResourceUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectPlurals childType) {
87
88         return new AAISimpleUri(parentUri, childType);
89     }
90
91     /**
92      * Creates a uri for a plural type e.g. /cloud-infrastructure/pservers
93      * 
94      * @param type
95      * @return
96      */
97     public static AAIResourceUri createResourceUri(AAIObjectPlurals type) {
98
99         return new AAISimpleUri(type);
100
101     }
102
103     /**
104      * Creates a uri for a plural type with values e.g. /cloud-infrastructure/pservers
105      * 
106      * @param type
107      * @return
108      */
109     public static AAIResourceUri createResourceUri(AAIObjectPlurals type, Object... values) {
110
111         return new AAISimpleUri(type, values);
112
113     }
114 }