mso.dme2.client.timeout=30000
mso.dme2.client.read.timeout=120000
+scheduler.user.name=test1
+scheduler.password=test2
+
scheduler.create.new.vnf.change.instance=/v1/ChangeManagement/schedules/
scheduler.get.time.slots=/v1/ChangeManagement/schedules/
scheduler.server.url=http://localhost:1080/scheduler
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@JsonIgnoreProperties(ignoreUnknown = true)
public class RelationshipList {
+ public List<Relationship> relationship;
+
@JsonProperty("relationship")
public List<Relationship> getRelationship() {
return relationship;
this.relationship = relationship;
}
- public List<Relationship> relationship;
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nokia. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public static ExceptionResponse handleException(Exception e, EELFLoggerDelegate logger) {
logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodCallerName(), ExceptionUtils.getMessage(e), e);
-
- ExceptionResponse exceptionResponse = new ExceptionResponse(e);
- return exceptionResponse;
+ return new ExceptionResponse(e);
}
public static ResponseEntity handleWebApplicationException(WebApplicationException e, EELFLoggerDelegate logger) {
package org.onap.vid.logging;
+import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
+import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Pointcut;
import org.onap.portalsdk.core.logging.aspect.EELFLoggerAdvice;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.service.AppService;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.web.support.UserUtils;
+import org.onap.vid.controller.ControllersUtils;
+import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
@Aspect
public class VidLoggerAspect {
private String canonicalHostName;
- @Autowired
- EELFLoggerAdvice advice;
+ private final ControllersUtils controllersUtils;
+ private final String appName;
+
+ private final EELFLoggerAdvice advice;
- public VidLoggerAspect() {
+ @Autowired
+ public VidLoggerAspect(EELFLoggerAdvice advice, SystemPropertiesWrapper systemPropertiesWrapper,
+ AppService appService) {
try {
final InetAddress localHost = InetAddress.getLocalHost();
canonicalHostName = localHost.getCanonicalHostName();
// YOLO
canonicalHostName = null;
}
+ this.advice = advice;
+ this.controllersUtils = new ControllersUtils(systemPropertiesWrapper);
+
+ this.appName = defaultIfEmpty(appService.getDefaultAppName(), SystemProperties.SDK_NAME);
}
- @Pointcut("execution(public * org.onap.vid.controller.*Controller.*(..))")
+ @Pointcut("execution(public * org.onap.vid.controller..*Controller.*(..))")
public void vidControllers() {}
@Around("vidControllers() && (" +
private Object logAroundMethod(ProceedingJoinPoint joinPoint, SystemProperties.SecurityEventTypeEnum securityEventType) throws Throwable {
//Before
Object[] passOnArgs = new Object[] {joinPoint.getSignature().getDeclaringType().getName(),joinPoint.getSignature().getName()};
- Object[] returnArgs = advice.before(securityEventType, joinPoint.getArgs(), passOnArgs);
+ Object[] returnArgs = advice.before(securityEventType, fabricateArgsWithNull(), passOnArgs);
+
+ fixSetRequestBasedDefaultsIntoGlobalLoggingContext(httpServletRequestOrNull(joinPoint),
+ joinPoint.getSignature().getDeclaringType().getName());
fixServerFqdnInMDC();
EELFLoggerDelegate.mdcPut(SystemProperties.STATUS_CODE, restStatus);
}
+ /**
+ * Returns an array with a single entry with a null value. This will stop org.onap.portalsdk.core.logging.aspect.EELFLoggerAdvice.before
+ * from throwing on ArrayIndexOutOfBound, and also prevent SessionExpiredException.
+ */
+ private Object[] fabricateArgsWithNull() {
+ return new Object[]{null};
+ }
+
+ /**
+ * Finds the first joinPoint's param which is an HttpServletRequest. If not found, use Spring's RequestContextHolder
+ * to retrieve it.
+ *
+ * @return null or the current httpServletRequest
+ */
+ private HttpServletRequest httpServletRequestOrNull(ProceedingJoinPoint joinPoint) {
+ final Object httpServletRequest = Arrays.stream(joinPoint.getArgs())
+ .filter(param -> param instanceof HttpServletRequest)
+ .findFirst()
+ .orElseGet(() -> {
+ try {
+ return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
+ } catch (Exception e) { // ClassCast, IllegalState, etc.
+ return null;
+ }
+ });
+
+ return (HttpServletRequest) httpServletRequest;
+ }
+
+ /**
+ * Mimics a part from org.onap.portalsdk.core.logging.aspect.EELFLoggerAdvice.before, but with much more carefulness
+ * of exceptions and defaults. Main difference is that if no session, function does not throw. It just fallback to
+ * an empty loginId.
+ */
+ private void fixSetRequestBasedDefaultsIntoGlobalLoggingContext(HttpServletRequest httpServletRequest, String className) {
+ if (httpServletRequest != null) {
+
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className);
+ String requestId = UserUtils.getRequestId(httpServletRequest);
+ String loginId = controllersUtils.extractUserId(httpServletRequest);
+
+ logger.setRequestBasedDefaultsIntoGlobalLoggingContext(httpServletRequest, appName, requestId, loginId);
+ }
+ }
+
// Override the non-canonical hostname set by EELFLoggerDelegate::setGlobalLoggingContext()
// that was invoked by advice.before() (and some other SDK cases)
private void fixServerFqdnInMDC() {
status = response.getStatus();
restObject.setStatusCode(status);
rawData = response.getBody();
+ restObject.setRaw(rawData);
if (status == 200) {
if (t instanceof String) {
restObject.set((T)rawData);
}
else {
- restObject.set(JACKSON_OBJECT_MAPPER.readValue(rawData, new TypeReference<T>() {}));
+ restObject.set(JACKSON_OBJECT_MAPPER.readValue(rawData, (Class<T>)t.getClass()));
}
logger.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + SUCCESSFUL_API_MESSAGE);
logger.info(EELFLoggerDelegate.errorLogger, "<== " + methodName + SUCCESSFUL_API_MESSAGE);
setTestMode();\r
\r
DataService.setSubscriberName("Mobility");\r
- DataService.setGlobalCustomerId("CUSTID12345")\r
+ DataService.setGlobalCustomerId("CUSTID12345");\r
DataService.setServiceType("Mobility Type 1");\r
DataService.setServiceName("Mobility Service 1");\r
DataService.setServiceInstanceId("mmsc-test-service-instance");\r
DataService.setVnfInstanceId("abcd-12345-56789");\r
DataService.setVfModuleInstanceId("xye-99990123213");\r
- }\r
+ };\r
\r
var TEST_MODE_COOKIE = "isTestModeEnabled";\r
\r
} else {\r
PropertyService.setMsoBaseUrl(defaultMsoBaseUrl);\r
}\r
- }\r
+ };\r
\r
$scope.autoStartCommitTest = function() {\r
/*\r
// $scope.deleteServiceInstance();\r
// $scope.generateInvalidUrl404(); \r
}, 500);\r
- }\r
+ };\r
\r
$scope.autoStartQueryTest = function() {\r
/*\r
$timeout(function() {\r
// $scope.queryServiceInstance();\r
}, 500);\r
- }\r
+ };\r
\r
$scope.queryServiceInstance = function() {\r
/*\r
$scope.$broadcast("showComponentDetails", {\r
componentId : COMPONENT.SERVICE\r
});\r
- }\r
+ };\r
\r
$scope.createServiceInstance = function() {\r
/*\r
url : "mso_create_svc_instance",\r
requestDetails : createServiceRequestDetails\r
});\r
- }\r
+ };\r
\r
$scope.deleteServiceInstance = function() {\r
/*\r
url : "mso_delete_svc_instance/bc305d54-75b4-431b-adb2-eb6b9e546014",\r
requestDetails : deleteServiceRequestDetails\r
});\r
- }\r
+ };\r
\r
$scope.createVNFInstance = function() {\r
/*\r
url : "mso_create_vnf_instance/bc305d54-75b4-431b-adb2-eb6b9e546099",\r
requestDetails : createVnfRequestDetails\r
});\r
- }\r
+ };\r
\r
$scope.deleteVNFInstance = function() {\r
/*\r
url : "mso_delete_vnf_instance/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/ab9000-0009-9999",\r
requestDetails : deleteVnfRequestDetails\r
});\r
- }\r
+ };\r
\r
$scope.createVolumeGroupInstance = function() {\r
/*\r
url : "mso_create_volumegroup_instance/bc305d54-75b4-431b-adb2-eb6b9e546099/vnfs/fe305d54-75b4-431b-adb2-eb6b9e546fea",\r
requestDetails : createVolumeGroupRequestDetails\r
});\r
- }\r
+ };\r
\r
$scope.deleteVolumeGroupInstance = function() {\r
/*\r
url : "mso_delete_volumegroup_instance/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe305d54-75b4-431b-adb2-eb6b9e546fea/volumeGroups/fe9000-0009-9999",\r
requestDetails : deleteVolumeGroupRequestDetails\r
});\r
- }\r
+ };\r
$scope.createVFModuleInstance = function() {\r
/*\r
* Example of method call needed to commit an instance creation request.\r
url : "mso_create_vfmodule_instance/bc305d54-75b4-431b-adb2-eb6b9e546099/vnfs/111-111-111-111",\r
requestDetails : createVFModuleRequestDetails\r
});\r
- }\r
+ };\r
\r
$scope.deleteVFModuleInstance = function() {\r
/*\r
url : "mso_create_nw_instance/789098877777",\r
requestDetails : createNetworkRequestDetails\r
});\r
- }\r
+ };\r
\r
$scope.deleteNetworkInstance = function() {\r
$scope.$broadcast("deleteInstance", {\r
url : "mso_delete_nw_instance/bc305d54-75b4-431b-adb2-eb6b9e546014/networks/ff305d54-75b4-ff1b-fff1-eb6b9e5460ff",\r
requestDetails : deleteNetworkRequestDetails\r
});\r
- }\r
+ };\r
\r
$scope.generateError = function(testName) {\r
// Clone example request object\r
url : "mso_create_svc_instance",\r
requestDetails : request\r
});\r
- }\r
+ };\r
\r
$scope.generateInvalidUrl404 = function() {\r
var baseUrl = PropertyService.getMsoBaseUrl();\r
$scope.popup.isVisible = false;\r
}\r
}); \r
- }\r
+ };\r
\r
$scope.generateInvalidUrl405 = function() {\r
$scope.$broadcast("createInstance", {\r
url : "INVALID_STRING_mso_create_svc_instance",\r
requestDetails : createServiceRequestDetails\r
});\r
- }\r
+ };\r
\r
/*\r
* Test data objects:\r
*/\r
\r
DataService.setSubscriberName("Mobility");\r
- DataService.setGlobalCustomerId("CUSTID12345")\r
+ DataService.setGlobalCustomerId("CUSTID12345");\r
DataService.setServiceType("Mobility Type 1");\r
DataService.setServiceInstanceName("Example Service Instance Name");\r
DataService.setServiceName("Mobility Service 1");\r
\r
setTestMode();\r
\r
- }\r
+ };\r
\r
$scope.autoStartTest = function() {\r
/*\r
// $scope.deleteVnf();\r
// $scope.createVfModule();\r
}, 500);\r
- }\r
+ };\r
\r
/*\r
* This block of code is only used for testing.\r
componentId : COMPONENT.SERVICE,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.createVnf = function() {\r
\r
DataService.setModelId("91238134091820938018230918230989");\r
DataService.setModelInstanceName("VNF_MODEL_INSTANCE_NAME");\r
\r
- DataService.setCloudRegionTenantList(exampleCloudRegionTenantList)\r
+ DataService.setCloudRegionTenantList(exampleCloudRegionTenantList);\r
DataService.setServiceIdList(exampleServiceIdList);\r
\r
// Data used to create MSO "relatedInstanceList" object\r
componentId : COMPONENT.VNF,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.createVfModule = function() {\r
DataService\r
componentId : COMPONENT.VF_MODULE,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.createVolumeGroup = function() {\r
\r
componentId : COMPONENT.VOLUME_GROUP,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.createNetwork = function() {\r
\r
componentId : COMPONENT.NETWORK,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
/*\r
* Delete functions\r
componentId : COMPONENT.SERVICE,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.deleteVnf = function() {\r
\r
componentId : COMPONENT.VNF,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.deleteVfModule = function() {\r
\r
componentId : COMPONENT.VF_MODULE,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.deleteVolumeGroup = function() {\r
\r
componentId : COMPONENT.VOLUME_GROUP,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.deleteNetwork = function() {\r
\r
componentId : COMPONENT.NETWORK,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
/*\r
* Show Details functions\r
componentId : COMPONENT.SERVICE,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.showVnfDetails = function() {\r
\r
componentId : COMPONENT.VNF,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.showVfModuleDetails = function() {\r
\r
componentId : COMPONENT.VF_MODULE,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.showVolumeGroupDetails = function() {\r
\r
componentId : COMPONENT.VOLUME_GROUP,\r
callbackFunction : callbackFunction\r
});\r
- }\r
+ };\r
\r
$scope.showNetworkDetails = function() {\r
\r
componentId : COMPONENT.NETWORK,\r
callbackFunction : callbackFunction\r
});\r
- }\r
-}\r
+ };\r
+};\r
\r
app.controller("testViewEditController", [ "COMPONENT", "DataService",\r
"PropertyService", "UtilityService", "$scope", "$timeout",\r
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.logging;
-
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.junit.Test;
-import org.onap.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum;
-
-
-public class VidLoggerAspectTest {
-
- private VidLoggerAspect createTestSubject() {
- return new VidLoggerAspect();
- }
-
- @Test
- public void testVidControllers() throws Exception {
- VidLoggerAspect testSubject;
-
- // default test
- testSubject = createTestSubject();
- testSubject.vidControllers();
- }
-
-}
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "AV_vPE"
},
"2017488pasqualevpe20_bandwidth": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "10"
},
"2017488pasqualevpe20_bandwidth_units": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "Gbps"
},
"2017488pasqualevpe20_AIC_CLLI": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "ATLMY8GA"
},
"2017488pasqualevpe20_vnf_config_template_version": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "17.2"
},
"2017488pasqualevpe20_vnf_instance_name": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "mtnj309me6"
}
}
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "17.2"
},
"bandwidth_units": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "Gbps"
},
"bandwidth": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "10"
},
"AIC_CLLI": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "ATLMY8GA"
},
"ASN": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "AV_vPE"
},
"vnf_instance_name": {
"inputProperties": null,
"constraints": [],
"required": true,
+ "templateName": null,
+ "templateUUID": null,
+ "templateInvariantUUID": null,
+ "templateCustomizationUUID": null,
"default": "mtnj309me6"
}
},