2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.openecomp.sdc.be.components.path.beans;
23 import fj.data.Either;
24 import org.openecomp.sdc.be.impl.ForwardingPathUtils;
25 import org.openecomp.sdc.be.model.Component;
26 import org.openecomp.sdc.be.model.Resource;
27 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
28 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
30 @org.springframework.stereotype.Component("tosca-operation-facade")
31 public class ForwardingPathToscaOperationFacade extends ToscaOperationFacade {
32 protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service";
34 public Either<Resource, StorageOperationStatus> getLatestCertifiedNodeTypeByToscaResourceName(String toscaResourceName) {
36 return Either.left(setupGenericServiceMock());
39 protected Resource setupGenericServiceMock(){
40 Resource genericService = new Resource();
41 genericService.setVersion("1.0");
42 genericService.setToscaResourceName(GENERIC_SERVICE_NAME);
43 return genericService;
47 public <T extends Component> Either<T, StorageOperationStatus> getLatestByName(String resourceName) {
48 if(resourceName.equals(ForwardingPathUtils.FORWARDING_PATH_NODE_NAME) || resourceName.equals(ForwardingPathUtils.FORWARDER_CAPABILITY)){
49 Resource component = new Resource();
50 component.setToscaResourceName(GENERIC_SERVICE_NAME);
51 return Either.left((T)component);
53 return super.getLatestByName(resourceName);
57 public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName) {
58 if(toscaResourceName.equals(ForwardingPathUtils.FORWARDING_PATH_NODE_NAME) || toscaResourceName.equals(ForwardingPathUtils.FORWARDER_CAPABILITY)){
59 Resource component = new Resource();
60 component.setToscaResourceName(GENERIC_SERVICE_NAME);
61 return Either.left((T)component);
63 return super.getLatestByToscaResourceName(toscaResourceName);