2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.introspection.sideeffect;
23 import java.io.UnsupportedEncodingException;
24 import java.net.URISyntaxException;
26 import java.util.List;
27 import java.util.Map.Entry;
28 import java.util.Optional;
29 import org.apache.tinkerpop.gremlin.structure.Vertex;
30 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
31 import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
32 import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
33 import org.onap.aai.exceptions.AAIException;
34 import org.onap.aai.introspection.Introspector;
35 import org.onap.aai.schema.enums.PropertyMetadata;
36 import org.onap.aai.serialization.db.DBSerializer;
37 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
39 public class OwnerCheck extends SideEffect {
41 public OwnerCheck(Introspector obj, Vertex self, TransactionalGraphEngine dbEngine, DBSerializer serializer) {
42 super(obj, self, dbEngine, serializer);
46 protected void processURI(Optional<String> completeUri, Entry<String, String> entry)
48 if (serializer.getGroups() != null && !serializer.getGroups().isEmpty()) {
49 List<Vertex> owningEntity = self.graph().traversal()
51 .inE("org.onap.relationships.inventory.BelongsTo")
53 .has("aai-node-type", "owning-entity")
56 if(!owningEntity.isEmpty()) {
57 VertexProperty owningEntityName = owningEntity.get(0).property("owning-entity-name");
59 if(!serializer.getGroups().contains(owningEntityName.orElseGet(null))) {
60 throw new AAIException("AAI_3304",
61 "Group(s) :" + serializer.getGroups() + " not authorized to perform function");
64 } //else skip processing because no required properties were specified
69 protected PropertyMetadata getPropertyMetadata() {
70 return PropertyMetadata.OWNER_CHECK;
74 protected boolean replaceWithWildcard() {