Commit c7c08a64 authored by Kristjan Kruus's avatar Kristjan Kruus Committed by GitHub

Merge pull request #80 from e-gov/develop

Develop
parents 72802754 104fc0f8
......@@ -417,7 +417,7 @@ public class InfoSystem {
}
/**
* Urility method for clearing security section of InfoSystem object.
* Utility method for clearing security section of InfoSystem object.
*/
public void clearSecuritySection() {
((ObjectNode) jsonContent).remove(SECURITY_SECTION_KEY);
......@@ -514,7 +514,22 @@ public class InfoSystem {
((InfoSystemDocumentMetadata) currentFileMetadata).getAccessRestrictionJson());
}
});
}
public void replaceFileUrl(String oldUrl, String newUrl) {
replaceFileUrl(oldUrl, newUrl, DOCUMENTS_KEY);
replaceFileUrl(oldUrl, newUrl, DATA_FILES_KEY);
}
private void replaceFileUrl(String oldUrl, String newUrl, String key) {
JsonNode filesNode = jsonContent.path(key);
if (filesNode.isArray()) {
for (JsonNode fileNode : filesNode) {
String url = fileNode.path(FILE_METADATA_URL_KEY).asText(null);
if (url.equals(oldUrl)) {
((ObjectNode) fileNode).put(FILE_METADATA_URL_KEY, newUrl);
}
}
}
}
}
......@@ -32,6 +32,7 @@ import static java.util.stream.Collectors.toList;
@Slf4j
public class FileService {
private static final String FILE_URL_PREFIX = "file://";
private static final String INLINE_CONTENT_DISPOSITION_TYPE = "inline";
private static final String ATTACHMENT_CONTENT_DISPOSITION_TYPE = "attachment";
private static final String CONTENT_DISPOSITION_TOKEN_DELIMITER = ";";
......@@ -187,4 +188,18 @@ public class FileService {
.map(STORAGE_FILE_RESOURCE_TO_FILE_RESOURCE_MODEL)
.collect(Collectors.toList()));
}
public void updateFilesUuid(InfoSystem infoSystem, UUID existingInfoSystemUuid) {
Stream.concat(infoSystem.getDocumentMetadata().stream(), infoSystem.getDataFileMetadata().stream())
.forEach(file -> {
if (file.getUrl().startsWith(FILE_URL_PREFIX)) {
String uuid = file.getUrl().substring(7);
String newUuid = fileRepository.createFileResourceFromExisting(
UUID.fromString(uuid),
existingInfoSystemUuid,
infoSystem.getUuid());
infoSystem.replaceFileUrl(file.getUrl(), FILE_URL_PREFIX + newUuid);
}
});
}
}
......@@ -2,6 +2,7 @@ package ee.ria.riha.web;
import ee.ria.riha.domain.model.InfoSystem;
import ee.ria.riha.domain.model.RelationType;
import ee.ria.riha.service.FileService;
import ee.ria.riha.service.InfoSystemDataObjectService;
import ee.ria.riha.service.InfoSystemService;
import ee.ria.riha.service.RelationService;
......@@ -40,6 +41,9 @@ public class InfoSystemController {
@Autowired
private RelationService relationService;
@Autowired
private FileService fileService;
@GetMapping
@ApiOperation("List all existing information systems")
@ApiPageableAndFilterableParams
......@@ -125,6 +129,10 @@ public class InfoSystemController {
.build()
);
//for all existing files, should create new entry into file_resource table with new info system UUID
fileService.updateFilesUuid(newlyCreatedInfoSystem, existingInfoSystem.getUuid());
infoSystemService.update(newlyCreatedInfoSystem.getUuid().toString(), newlyCreatedInfoSystem);
return ResponseEntity.ok(infoSystemModelMapper.map(newlyCreatedInfoSystem));
}
......
......@@ -39,7 +39,7 @@
</div>
<div class="form-group">
Detailne andmekoosseis:
<app-tooltip [placement]="'bottom-right'" [text]="'Infosüsteemi detailne andmete koosseis, mis on andmeobjektideks lahti kirjutatud ning annab ülevaate kogu infost, mida andmekogus hoitakse. Lisatuna csv, xmi või andmebaasi skeema kirjeldusena, milles on põhiandmed eraldi välja toodud'"></app-tooltip>
<app-tooltip [placement]="'bottom-right'" [text]="'Andmeobjektide detailne nimekiri, milles on esitatud isikuandmed, eriliiki isikuandmed ja põhiandmed: mallikohane csv-, xls- või xlsx-fail, mis kasutab koodisüsteemi Windows-1257'"></app-tooltip>
</div>
<div *ngIf="dataFile == null" class="form-group">
<label class="btn btn-default input-file-label mb-0" for="dataFile"><i class="fa fa-plus fa-fw" aria-hidden="true"></i>&nbsp; Laadi fail</label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment