Fix #1504: FQN of Location is null.s3://bucket/... and service is saved in location_entity (#1506)

This commit is contained in:
Alberto Miorin 2021-12-02 08:36:34 +01:00 committed by GitHub
parent a0045a437c
commit 5938ea20bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
/*
* Copyright 2021 Collate
* Copyright 2021 Collate
* 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
@ -144,6 +144,8 @@ public class LocationRepository extends EntityRepository<Location> {
@Override
public void prepare(Location location) throws IOException {
EntityReference storageService = getService(location.getService());
location.setService(storageService);
// Set data in location entity based on storage relationship
location.setFullyQualifiedName(getFQN(location));
@ -162,7 +164,7 @@ public class LocationRepository extends EntityRepository<Location> {
List<TagLabel> tags = location.getTags();
// Don't store owner, href and tags as JSON. Build it on the fly based on relationships
location.withOwner(null).withHref(null).withTags(null);
location.withOwner(null).withService(null).withHref(null).withTags(null);
if (update) {
dao.locationDAO().update(location.getId(), JsonUtils.pojoToJson(location));