* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
protected static int createCorruptSession() {
final var apexEditorRestResource = new ApexEditorRestResource();
final ApexApiResult result = apexEditorRestResource.createSession();
- final int corruptSessionId = Integer.parseInt(result.getMessages().get(0));
+ final var corruptSessionId = Integer.parseInt(result.getMessages().get(0));
SESSION_HANDLER.setCorruptSession(corruptSessionId);
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.gui.editors.apex.rest.handling;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import java.util.ArrayList;
* @return The list result, containing JSON augmented representations of objects stored in its "messages" array
*/
private ApexApiResult addKeyInfo2Messages(final RestSession session, final ApexApiResult incomingResult) {
- final ApexApiResult result = new ApexApiResult(incomingResult.getResult());
+ final var result = new ApexApiResult(incomingResult.getResult());
result.setMessages(incomingResult.getMessages());
final List<String> messages = incomingResult.getMessages();
* @return the augmented message
*/
private String addKeyInfo2Message(final RestSession session, final String message) {
- final Gson gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
+ final var gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
var jsonObject = gson.fromJson(message, JsonObject.class);
if (jsonObject == null) {
private boolean setUuidAndDescription(final RestSession session, JsonObject jsonObject, String name,
String version) {
// Look up the key information for the name and version
- JsonObject keyInfoJsonObject = lookupKeyInfo(session, name, version);
+ var keyInfoJsonObject = lookupKeyInfo(session, name, version);
if (keyInfoJsonObject == null || keyInfoJsonObject.get(APEX_KEY_INFO) != null) {
return false;
}
return null;
}
- final Gson gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
+ final var gson = new GsonBuilder().serializeNulls().enableComplexMapKeySerialization().create();
final String keyInfoJson = keyInfoMessages.get(0);
return gson.fromJson(keyInfoJson, JsonObject.class);
}
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
AxArtifactKey policyModelKey = apexModelBeingUploaded.getPolicyModel().getKey();
- String policyModelUUid = apexModelBeingUploaded.getPolicyModel().getKeyInformation().get(policyModelKey)
+ var policyModelUUid = apexModelBeingUploaded.getPolicyModel().getKeyInformation().get(policyModelKey)
.getUuid().toString();
return new PolicyUploadHandler().doUpload(result.getMessage(), policyModelKey, policyModelUUid);
}
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
}
if (val.isJsonArray()) {
final var arr = val.getAsJsonArray();
- for (int i = 0; i < arr.size(); i++) {
+ for (var i = 0; i < arr.size(); i++) {
arr.set(i, blank2null(arr.get(i)));
}
}
public static <C extends AxConcept> C getConceptFromJson(final String jsonString, final Class<C> clz)
throws JAXBException {
Unmarshaller unmarshaller = null;
- final JAXBContext jaxbContext = JAXBContext.newInstance(clz);
+ final var jaxbContext = JAXBContext.newInstance(clz);
unmarshaller = jaxbContext.createUnmarshaller();
if (jsonString.matches(JSON_INPUT_TYPE_REGEXP)) {
unmarshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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 javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
LOGGER.entry();
if (StringUtils.isBlank(ApexEditorMain.getParameters().getUploadUrl())) {
- final ApexApiResult apexApiResult = new ApexApiResult(Result.FAILED);
+ final var apexApiResult = new ApexApiResult(Result.FAILED);
apexApiResult.addMessage("Model upload is disabled, parameter upload-url is not set on server");
LOGGER.exit(MODEL_UPLOAD_NOT_OK);
return apexApiResult;
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
final var stringWriter = new StringWriter();
final var stringPrintWriter = new PrintWriter(stringWriter);
- final HelpFormatter helpFormatter = new HelpFormatter();
+ final var helpFormatter = new HelpFormatter();
helpFormatter.printHelp(stringPrintWriter, 120, mainClassName + " [options...] ", "", options, 0, 0, "");
return stringWriter.toString();
* ============LICENSE_START=======================================================
* Copyright (C) 2020-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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 org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpEngineWorkerStatistics;
import org.onap.policy.models.pdp.concepts.PdpGroups;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
throw new IllegalArgumentException("Cannot parse groupName, subGroup and instanceId from " + id);
}
- Pdp pdp = pdpGroups.getGroups().stream().filter(group -> group.getName().equals(groupName))
+ var pdp = pdpGroups.getGroups().stream().filter(group -> group.getName().equals(groupName))
.flatMap(group -> group.getPdpSubgroups().stream().filter(sub -> sub.getPdpType().equals(subGroup)))
.flatMap(sub -> sub.getPdpInstances().stream()
.filter(instance -> instance.getInstanceId().equals(instanceId)))
final List<EngineStatus> engineStatusList = new ArrayList<>();
if (!pdpStats.isEmpty()) {
- PdpStatistics pdpStatistics = pdpStats.get(groupName).get(subGroup).get(0);
+ var pdpStatistics = pdpStats.get(groupName).get(subGroup).get(0);
responseObject.setTimeStamp(pdpStatistics.getTimeStamp().toString());
responseObject.setPolicyDeployCount(pdpStatistics.getPolicyDeployCount());
responseObject.setPolicyDeploySuccessCount(pdpStatistics.getPolicyDeploySuccessCount());
// Engine Status data
for (final PdpEngineWorkerStatistics engineStats : pdpStatistics.getEngineStats()) {
try {
- final EngineStatus engineStatusObject = new EngineStatus();
+ final var engineStatusObject = new EngineStatus();
engineStatusObject.setTimestamp(pdpStatistics.getTimeStamp().toString());
engineStatusObject.setId(engineStats.getEngineId());
engineStatusObject.setStatus(engineStats.getEngineWorkerState().name());