* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.aai;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* Constants used with A&AI classes.
*/
-public class AaiConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class AaiConstants {
public static final String ACTOR_NAME = "AAI";
public static final String CONTEXT_PREFIX = ACTOR_NAME + ".";
-
- private AaiConstants() {
- // do nothing
- }
}
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
+import lombok.AllArgsConstructor;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;
import org.json.JSONObject;
/**
* This class handles communication towards and responses from A&AI for this module.
*/
+@AllArgsConstructor
public final class AaiManager {
// TODO remove this class
private static final StandardCoder CODER = new StandardCoder();
- // The REST manager used for processing REST calls for this AAI manager
- private final RestManager restManager;
-
/** custom query and other AAI resource URLs. */
private static final String CQ_URL = "/aai/v21/query?format=resource";
private static final String TENANT_URL = "/aai/v21/search/nodes-query?"
private static final String PNF_URL = PREFIX + "/network/pnfs/pnf/";
private static final String AAI_DEPTH_SUFFIX = "?depth=0";
- /**
- * Constructor, create the AAI manager with the specified REST manager.
- *
- * @param restManager the rest manager to use for REST calls
- */
- public AaiManager(final RestManager restManager) {
- this.restManager = restManager;
- }
+ // The REST manager used for processing REST calls for this AAI manager
+ private final RestManager restManager;
/**
* Creates the custom query payload from a tenant query response.
* ============LICENSE_START=======================================================
* aai
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class Serialization {
public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
-
- private Serialization() {
- // Private constructor to prevent subclassing
- }
}
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import java.util.UUID;
import lombok.EqualsAndHashCode;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
+import lombok.ToString;
@Getter
@Setter
@EqualsAndHashCode
+@NoArgsConstructor
+@ToString
public class CommonHeader implements Serializable {
private static final long serialVersionUID = -3581658269910980336L;
@SerializedName("Flags")
private Collection<Map<String, String>> flags = new ArrayList<>();
- public CommonHeader() {
- // Default constructor
- }
-
/**
* Construct an instance from an existing instance.
*
this.flags.addAll(commonHeader.flags);
}
}
-
- @Override
- public String toString() {
- return "CommonHeader [TimeStamp=" + timeStamp + ", APIver=" + apiVer + ", OriginatorId=" + originatorId
- + ", RequestId=" + requestId + ", SubrequestId=" + subRequestId + ", RequestTrack=" + requestTrack
- + ", Flags=" + flags + "]";
- }
}
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
+import lombok.ToString;
@Getter
@Setter
@EqualsAndHashCode
+@NoArgsConstructor
+@ToString
public class Request implements Serializable {
private static final long serialVersionUID = -3912323643990646431L;
@SerializedName("Payload")
private Map<String, Object> payload = new HashMap<>();
-
- public Request() {
- // Initiate an empty Request instance
- }
-
- @Override
- public String toString() {
- return "Request [CommonHeader=" + commonHeader + ", Action=" + action + ", TargetId=" + targetId + ", ObjectId="
- + objectId + ", Payload=" + payload + "]";
- }
-
}
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
+import lombok.ToString;
@Getter
@Setter
@EqualsAndHashCode
+@NoArgsConstructor
+@ToString
public class Response implements Serializable {
private static final long serialVersionUID = 434953706339865151L;
@SerializedName("Payload")
private Map<String, Object> payload = new HashMap<>();
- public Response() {
-
- }
-
/**
* Construct an instance from an existing instance.
*
this.payload.putAll(request.getPayload());
}
}
-
- @Override
- public String toString() {
- return "Response [CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" + payload + "]";
- }
}
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
+import lombok.ToString;
@Getter
@Setter
+@EqualsAndHashCode
+@ToString
public class ResponseStatus implements Serializable {
private static final long serialVersionUID = 2421770469587860452L;
@SerializedName("Description")
private String description;
-
- @Override
- public String toString() {
- return "ResponseStatus [Code=" + code + ", Value=" + value + ", Description=" + description + "]";
- }
-
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + code;
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ResponseStatus other = (ResponseStatus) obj;
- if (code != other.code) {
- return false;
- }
- if (description == null) {
- if (other.description != null) {
- return false;
- }
- } else if (!description.equals(other.description)) {
- return false;
- }
- if (value == null) {
- if (other.value != null) {
- return false;
- }
- } else if (!value.equals(other.value)) {
- return false;
- }
- return true;
- }
-
}
import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.onap.policy.common.gson.InstantAsMillisTypeAdapter;
import org.onap.policy.common.gson.ZonedDateTimeTypeAdapter;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class Serialization {
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
// .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance())
// .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus())
.create();
-
- private Serialization() {
- // Private constructor to prevent subclassing
- }
}
package org.onap.policy.appc;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
assertNotEquals(0, commonHeader.hashCode());
- assertEquals("CommonHeader [TimeStamp=", commonHeader.toString().substring(0, 24));
+ assertThat(commonHeader.toString()).startsWith("CommonHeader(timeStamp=");
CommonHeader copiedCommonHeader = new CommonHeader();
copiedCommonHeader.setApiVer(commonHeader.getApiVer());
package org.onap.policy.appc;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
assertNotEquals(0, request.hashCode());
- assertEquals("Request [CommonHeader=CommonHeader [TimeStamp=", request.toString().substring(0, 46));
+ assertThat(request.toString()).startsWith("Request(commonHeader=CommonHeader(timeStamp=");
Request copiedRequest = new Request();
copiedRequest.setCommonHeader(request.getCommonHeader());
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.appc;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
assertEquals(THERE_S_NO_PLACE_LIKE_HOME, status.getValue());
assertNotEquals(0, status.hashCode());
- assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47));
+ assertThat(status.toString()).startsWith("ResponseStatus(code=1234, value=There's no pla");
ResponseStatus copiedStatus = new ResponseStatus();
copiedStatus.setCode(status.getCode());
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.appc;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
assertNotEquals(0, response.hashCode());
- assertEquals("Response [CommonHeader=CommonHeader [TimeStamp=", response.toString().substring(0, 47));
+ assertThat(response.toString()).startsWith("Response(commonHeader=CommonHeader(timeStamp=");
Response copiedResponse = new Response();
copiedResponse.setCommonHeader(response.getCommonHeader());
package org.onap.policy.appclcm;
import java.io.Serializable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
import org.onap.policy.appclcm.util.StatusCodeEnum;
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
public class AppcLcmResponseCode implements Serializable {
/* These fields define the key to the response code value. */
public static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
private static final long serialVersionUID = 8189456447227022582L;
- private final Integer code;
-
- protected AppcLcmResponseCode(final int code) {
- this.code = code;
- }
-
- public int getCode() {
- return this.code;
- }
+ @Getter
+ private final int code;
@Override
public String toString() {
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.time.Instant;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.onap.policy.common.gson.InstantAsMillisTypeAdapter;
import org.onap.policy.common.gson.InstantTypeAdapter;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class Serialization {
public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
.registerTypeAdapter(Instant.class, new InstantTypeAdapter()).create();
public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
.registerTypeAdapter(Instant.class, new InstantAsMillisTypeAdapter()).create();
-
- private Serialization() {
- // Private constructor to prevent subclassing
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private String requestId;
private String status;
-
- /**
- * Default empty constructor.
- */
- public CdsResponse() {
- super();
- }
-
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Bell Canada.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import io.grpc.Metadata;
import io.grpc.Metadata.Key;
import io.grpc.MethodDescriptor;
+import lombok.AllArgsConstructor;
import org.onap.policy.cds.properties.CdsServerProperties;
/**
* On the server side, CDS BasicAuthServerInterceptor (1) gets the client metadata from the server context, (2) extract
* the "Authorization" header key and finally (3) decodes the username and password from the authHeader.</p>
*/
+@AllArgsConstructor
public class BasicAuthClientHeaderInterceptor implements ClientInterceptor {
static final String BASIC_AUTH_HEADER_KEY = "Authorization";
private CdsServerProperties props;
- BasicAuthClientHeaderInterceptor(CdsServerProperties props) {
- this.props = props;
- }
-
@Override
public <Q, P> ClientCall<Q, P> interceptCall(MethodDescriptor<Q, P> method,
CallOptions callOptions, Channel channel) {
import io.grpc.ManagedChannel;
import io.grpc.stub.StreamObserver;
import java.util.concurrent.CountDownLatch;
+import lombok.AllArgsConstructor;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@AllArgsConstructor
public class CdsProcessorHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(CdsProcessorHandler.class);
private static final String LOG_MSG = "[{}|{}|{}|]{}{}";
private CdsProcessorListener listener;
private String url;
- CdsProcessorHandler(final CdsProcessorListener listener, String url) {
- this.listener = listener;
- this.url = url;
- }
-
CountDownLatch process(ExecutionServiceInput request, ManagedChannel channel) {
final var header = request.getActionIdentifiers();
LOGGER.info("Processing blueprint({}:{}) for action({})", header.getBlueprintVersion(),