2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.synchronizer.task;
25 import java.util.function.Supplier;
27 import org.onap.aai.sparky.dal.NetworkTransaction;
28 import org.onap.aai.sparky.dal.aai.ActiveInventoryDataProvider;
29 import org.onap.aai.sparky.dal.rest.OperationResult;
32 * The Class CollectEntitySelfLinkTask.
34 public class CollectEntitySelfLinkTask implements Supplier<NetworkTransaction> {
36 private NetworkTransaction txn;
38 private ActiveInventoryDataProvider provider;
41 * Instantiates a new collect entity self link task.
44 * @param provider the provider
46 public CollectEntitySelfLinkTask(NetworkTransaction txn, ActiveInventoryDataProvider provider) {
48 this.provider = provider;
54 * @see java.util.function.Supplier#get()
57 public NetworkTransaction get() {
61 long startTimeInMs = System.currentTimeMillis();
62 OperationResult result = null;
64 result = provider.queryActiveInventoryWithRetries(txn.getLink(), "application/json", 5);
65 } catch (Exception exc) {
66 result = new OperationResult(500,
67 "Caught an exception while trying to resolve link = " + exc.getMessage());
69 result.setResponseTimeInMs(System.currentTimeMillis() - startTimeInMs);
70 txn.setOperationResult(result);
79 public NetworkTransaction getTxn() {
84 * @param txn the txn to set
86 public void setTxn(NetworkTransaction txn) {
91 * @return the provider
93 public ActiveInventoryDataProvider getProvider() {
98 * @param provider the provider to set
100 public void setProvider(ActiveInventoryDataProvider provider) {
101 this.provider = provider;