getDbEngine().startTransaction();
this.notification = new UEBNotification(loader, loaderFactory, schemaVersions);
- if("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))){
+ if ("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))) {
this.notificationDepth = AAIProperties.MAXIMUM_DEPTH;
} else {
this.notificationDepth = AAIProperties.MINIMUM_DEPTH;
getDbEngine().startTransaction();
this.notification = new UEBNotification(loader, loaderFactory, schemaVersions);
- if("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))){
+ if ("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))) {
this.notificationDepth = AAIProperties.MAXIMUM_DEPTH;
} else {
this.notificationDepth = AAIProperties.MINIMUM_DEPTH;
this.notification = notification;
- if("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))){
+ if ("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))) {
this.notificationDepth = AAIProperties.MAXIMUM_DEPTH;
} else {
this.notificationDepth = AAIProperties.MINIMUM_DEPTH;
if (obj != null) {
status = Status.OK;
MarshallerProperties properties;
- if (!request.getMarshallerProperties().isPresent()) {
- properties = new MarshallerProperties.Builder(
- org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build();
+ Optional<MarshallerProperties> marshallerPropOpt = request.getMarshallerProperties();
+ if (marshallerPropOpt.isPresent()) {
+ properties = marshallerPropOpt.get();
} else {
- properties = request.getMarshallerProperties().get();
+ properties = new MarshallerProperties.Builder(
+ org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build();
}
result = obj.marshal(properties);
}
result = formatter.output(vertices.stream().map(vertex -> (Object) vertex)
.collect(Collectors.toList())).toString();
- if(outputMediaType == null){
+ if (outputMediaType == null) {
outputMediaType = MediaType.APPLICATION_JSON;
}
- if(MediaType.APPLICATION_XML_TYPE.isCompatible(MediaType.valueOf(outputMediaType))){
+ if (MediaType.APPLICATION_XML_TYPE.isCompatible(MediaType.valueOf(outputMediaType))) {
result = xmlFormatTransformer.transform(result);
}
status = Status.OK;
result = formatter.output(vertices.stream().map(vertex -> (Object) vertex)
.collect(Collectors.toList())).toString();
- if(outputMediaType == null){
+ if (outputMediaType == null) {
outputMediaType = MediaType.APPLICATION_JSON;
}
- if(MediaType.APPLICATION_XML_TYPE.isCompatible(MediaType.valueOf(outputMediaType))){
+ if (MediaType.APPLICATION_XML_TYPE.isCompatible(MediaType.valueOf(outputMediaType))) {
result = xmlFormatTransformer.transform(result);
}
status = Status.OK;
if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
Map<String, Pair<Introspector, LinkedHashMap<String,Introspector>>> allImpliedDeleteObjs = serializer.getImpliedDeleteUriObjectPair();
- for(Map.Entry<String, Pair<Introspector, LinkedHashMap<String,Introspector>>> entry: allImpliedDeleteObjs.entrySet()){
+ for (Map.Entry<String, Pair<Introspector, LinkedHashMap<String,Introspector>>> entry: allImpliedDeleteObjs.entrySet()) {
// The format is purposefully %s/%s%s due to the fact
// that every aai-uri will have a slash at the beginning
// If that assumption isn't true, then its best to change this code
/**
* Generate notification events for the resulting db requests.
*/
- private void generateEvents(String sourceOfTruth, DBSerializer serializer, String transactionId, QueryEngine queryEngine, Set<Vertex> mainVertexesToNotifyOn) throws AAIException {
+ private void generateEvents(String sourceOfTruth, DBSerializer serializer, String transactionId,
+ QueryEngine queryEngine, Set<Vertex> mainVertexesToNotifyOn)
+ throws AAIException {
if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
- serializer.getUpdatedVertexes().entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey).forEach(mainVertexesToNotifyOn::add);
+ serializer.getUpdatedVertexes().entrySet().stream().filter(Map.Entry::getValue)
+ .map(Map.Entry::getKey).forEach(mainVertexesToNotifyOn::add);
}
Set<Vertex> edgeVertexes = serializer.touchStandardVertexPropertiesForEdges().stream()
.filter(v -> !mainVertexesToNotifyOn.contains(v)).collect(Collectors.toSet());
// Since @Autowired required is set to false, we need to do a null check
// for the existence of the validationService since its only enabled if profile is enabled
- if(validationService != null){
+ if (validationService != null){
validationService.validate(notification.getEvents());
}
notification.triggerEvents();
if (isDeltaEventsEnabled) {
try {
- DeltaEvents deltaEvents = new DeltaEvents(transactionId, sourceOfTruth, version.toString(), serializer.getObjectDeltas());
+ DeltaEvents deltaEvents =
+ new DeltaEvents(transactionId, sourceOfTruth, version.toString(),
+ serializer.getObjectDeltas());
deltaEvents.triggerEvents();
} catch (Exception e) {
LOGGER.error("Error sending Delta Events", e);
*/
private void createNotificationEvents(Set<Vertex> vertexesToNotifyOn, String sourceOfTruth, DBSerializer serializer,
String transactionId, QueryEngine queryEngine, int eventDepth) throws AAIException, UnsupportedEncodingException {
- for(Vertex vertex : vertexesToNotifyOn){
+ for (Vertex vertex : vertexesToNotifyOn) {
if (canGenerateEvent(vertex)) {
boolean isCurVertexNew = vertex.value(AAIProperties.CREATED_TS).equals(vertex.value(AAIProperties.LAST_MOD_TS));
Status curObjStatus = (isCurVertexNew) ? Status.CREATED : Status.OK;
if (!curObj.isTopLevel()) {
curRelatedObjs = serializer.getRelatedObjects(queryEngine, vertex, curObj, this.loader);
}
- notification.createNotificationEvent(transactionId, sourceOfTruth, curObjStatus, URI.create(uri), curObj, curRelatedObjs, basePath);
+ notification.createNotificationEvent(transactionId, sourceOfTruth, curObjStatus,
+ URI.create(uri), curObj, curRelatedObjs, basePath);
}
}
}
private boolean canGenerateEvent(Vertex vertex) {
boolean canGenerate = true;
try {
- if(!vertex.property(AAIProperties.AAI_URI).isPresent()){
+ if (!vertex.property(AAIProperties.AAI_URI).isPresent()) {
LOGGER.debug("Encountered an vertex {} with missing aai-uri", vertex.id());
canGenerate = false;
- } else if(!vertex.property(AAIProperties.CREATED_TS).isPresent() || !vertex.property(AAIProperties.LAST_MOD_TS).isPresent()){
+ } else if (!vertex.property(AAIProperties.CREATED_TS).isPresent() ||
+ !vertex.property(AAIProperties.LAST_MOD_TS).isPresent()) {
LOGGER.debug("Encountered an vertex {} with missing timestamp", vertex.id());
canGenerate = false;
}