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.apache.commons.lang3.StringUtils;
25 import org.openecomp.sdc.be.impl.ForwardingPathUtils;
26 import org.openecomp.sdc.be.model.Component;
27 import org.openecomp.sdc.be.model.Resource;
28 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
29 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
31 @org.springframework.stereotype.Component("tosca-operation-facade")
32 public class ForwardingPathToscaOperationFacade extends ToscaOperationFacade {
33 protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service";
35 public Either<Resource, StorageOperationStatus> getLatestCertifiedNodeTypeByToscaResourceName(String toscaResourceName) {
37 return Either.left(setupGenericServiceMock());
40 protected Resource setupGenericServiceMock(){
41 Resource genericService = new Resource();
42 genericService.setVersion("1.0");
43 genericService.setToscaResourceName(GENERIC_SERVICE_NAME);
44 return genericService;
48 public <T extends Component> Either<T, StorageOperationStatus> getLatestByName(String resourceName, String model) {
49 if(resourceName.equals(ForwardingPathUtils.FORWARDING_PATH_NODE_NAME) || resourceName.equals(ForwardingPathUtils.FORWARDER_CAPABILITY)){
50 Resource component = new Resource();
51 component.setToscaResourceName(GENERIC_SERVICE_NAME);
52 return Either.left((T)component);
54 return super.getLatestByName(resourceName, null);
58 public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName, String model) {
59 if(toscaResourceName.equals(ForwardingPathUtils.FORWARDING_PATH_NODE_NAME) || toscaResourceName.equals(ForwardingPathUtils.FORWARDER_CAPABILITY)){
60 Resource component = new Resource();
61 component.setToscaResourceName(GENERIC_SERVICE_NAME);
62 return Either.left((T)component);
64 return super.getLatestByToscaResourceName(toscaResourceName, model);