-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
story #12159 feat(archive-unit): add async bulk update api on archive…
… unit descriptive metadata
- Loading branch information
Showing
39 changed files
with
2,189 additions
and
1,423 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...arch-commons/src/main/java/fr/gouv/vitamui/archives/search/common/dto/BulkCommandDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) | ||
* | ||
* contact.vitam@culture.gouv.fr | ||
* | ||
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing | ||
* high volumetry securely and efficiently. | ||
* | ||
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free | ||
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as | ||
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". | ||
* | ||
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, | ||
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the | ||
* successive licensors have only limited liability. | ||
* | ||
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or | ||
* developing or reproducing the software by the user in light of its specific status of free software, that may mean | ||
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and | ||
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the | ||
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data | ||
* to be ensured and, more generally, to use and operate it in the same conditions as regards security. | ||
* | ||
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you | ||
* accept its terms. | ||
*/ | ||
|
||
package fr.gouv.vitamui.archives.search.common.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.Data; | ||
import lombok.NonNull; | ||
|
||
import javax.validation.constraints.Size; | ||
import java.util.Collection; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; | ||
|
||
@Data | ||
@JsonInclude(NON_NULL) | ||
public class BulkCommandDto { | ||
@NonNull | ||
@Size(min = 1, message = "Requires at least one command to play a bulk operation") | ||
@JsonProperty("queries") | ||
private Collection<ObjectNode> commands; | ||
|
||
private Integer threshold; | ||
} |
45 changes: 45 additions & 0 deletions
45
...search-commons/src/main/java/fr/gouv/vitamui/archives/search/common/dto/JsonPatchDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) | ||
* | ||
* contact.vitam@culture.gouv.fr | ||
* | ||
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing | ||
* high volumetry securely and efficiently. | ||
* | ||
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free | ||
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as | ||
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". | ||
* | ||
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, | ||
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the | ||
* successive licensors have only limited liability. | ||
* | ||
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or | ||
* developing or reproducing the software by the user in light of its specific status of free software, that may mean | ||
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and | ||
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the | ||
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data | ||
* to be ensured and, more generally, to use and operate it in the same conditions as regards security. | ||
* | ||
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you | ||
* accept its terms. | ||
*/ | ||
|
||
package fr.gouv.vitamui.archives.search.common.dto; | ||
|
||
import fr.gouv.vitamui.archives.search.common.model.JsonPatch; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.experimental.Accessors; | ||
|
||
import javax.validation.constraints.Size; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@Accessors(chain = true) | ||
public class JsonPatchDto { | ||
@NonNull private String id; | ||
@NonNull private JsonPatch jsonPatch; | ||
} |
38 changes: 38 additions & 0 deletions
38
...h-commons/src/main/java/fr/gouv/vitamui/archives/search/common/dto/MultiJsonPatchDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) | ||
* | ||
* contact.vitam@culture.gouv.fr | ||
* | ||
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing | ||
* high volumetry securely and efficiently. | ||
* | ||
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free | ||
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as | ||
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". | ||
* | ||
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, | ||
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the | ||
* successive licensors have only limited liability. | ||
* | ||
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or | ||
* developing or reproducing the software by the user in light of its specific status of free software, that may mean | ||
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and | ||
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the | ||
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data | ||
* to be ensured and, more generally, to use and operate it in the same conditions as regards security. | ||
* | ||
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you | ||
* accept its terms. | ||
*/ | ||
|
||
package fr.gouv.vitamui.archives.search.common.dto; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
import java.util.ArrayList; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
public class MultiJsonPatchDto extends ArrayList<JsonPatchDto> { | ||
} |
39 changes: 39 additions & 0 deletions
39
...arch-commons/src/main/java/fr/gouv/vitamui/archives/search/common/dto/OperationIdDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) | ||
* | ||
* contact.vitam@culture.gouv.fr | ||
* | ||
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing | ||
* high volumetry securely and efficiently. | ||
* | ||
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free | ||
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as | ||
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". | ||
* | ||
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, | ||
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the | ||
* successive licensors have only limited liability. | ||
* | ||
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or | ||
* developing or reproducing the software by the user in light of its specific status of free software, that may mean | ||
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and | ||
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the | ||
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data | ||
* to be ensured and, more generally, to use and operate it in the same conditions as regards security. | ||
* | ||
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you | ||
* accept its terms. | ||
*/ | ||
|
||
package fr.gouv.vitamui.archives.search.common.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import fr.gouv.vitamui.archives.search.common.model.OperationId; | ||
import lombok.Data; | ||
import lombok.experimental.Accessors; | ||
|
||
@Data | ||
@Accessors(chain = true) | ||
public class OperationIdDto { | ||
private OperationId operationId; | ||
} |
59 changes: 59 additions & 0 deletions
59
...ommons/src/main/java/fr/gouv/vitamui/archives/search/common/dto/UpdateArchiveUnitDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) | ||
* | ||
* contact.vitam@culture.gouv.fr | ||
* | ||
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing | ||
* high volumetry securely and efficiently. | ||
* | ||
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free | ||
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as | ||
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". | ||
* | ||
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, | ||
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the | ||
* successive licensors have only limited liability. | ||
* | ||
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or | ||
* developing or reproducing the software by the user in light of its specific status of free software, that may mean | ||
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and | ||
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the | ||
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data | ||
* to be ensured and, more generally, to use and operate it in the same conditions as regards security. | ||
* | ||
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you | ||
* accept its terms. | ||
*/ | ||
|
||
package fr.gouv.vitamui.archives.search.common.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class UpdateArchiveUnitDto { | ||
@NonNull | ||
@JsonProperty("#id") | ||
private String id; | ||
private Map<String, Object> additionalProperties = new HashMap<>(); | ||
|
||
@JsonAnyGetter | ||
public Map<String, Object> getAdditionalProperties() { | ||
return additionalProperties; | ||
} | ||
|
||
@JsonAnySetter | ||
public void setAdditionalProperties(String key, Object value) { | ||
additionalProperties.put(key, value); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...vitamui/archives/search/common/dto/converter/JsonPatchDtoToUpdateMultiQueryConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) | ||
* | ||
* contact.vitam@culture.gouv.fr | ||
* | ||
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing | ||
* high volumetry securely and efficiently. | ||
* | ||
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free | ||
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as | ||
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". | ||
* | ||
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, | ||
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the | ||
* successive licensors have only limited liability. | ||
* | ||
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or | ||
* developing or reproducing the software by the user in light of its specific status of free software, that may mean | ||
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and | ||
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the | ||
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data | ||
* to be ensured and, more generally, to use and operate it in the same conditions as regards security. | ||
* | ||
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you | ||
* accept its terms. | ||
*/ | ||
|
||
package fr.gouv.vitamui.archives.search.common.dto.converter; | ||
|
||
import fr.gouv.vitam.common.database.builder.query.Query; | ||
import fr.gouv.vitam.common.database.builder.query.QueryHelper; | ||
import fr.gouv.vitam.common.database.builder.query.action.Action; | ||
import fr.gouv.vitam.common.database.builder.request.exception.InvalidCreateOperationException; | ||
import fr.gouv.vitam.common.database.builder.request.multiple.UpdateMultiQuery; | ||
import fr.gouv.vitamui.archives.search.common.dto.JsonPatchDto; | ||
import fr.gouv.vitamui.archives.search.common.exception.DslQueryCreateException; | ||
import fr.gouv.vitamui.commons.api.logger.VitamUILogger; | ||
import fr.gouv.vitamui.commons.api.logger.VitamUILoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.stereotype.Service; | ||
|
||
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.GUID; | ||
import static java.util.Objects.nonNull; | ||
|
||
@Service | ||
public class JsonPatchDtoToUpdateMultiQueryConverter implements Converter<JsonPatchDto, UpdateMultiQuery> { | ||
private static final VitamUILogger log = | ||
VitamUILoggerFactory.getInstance(JsonPatchDtoToUpdateMultiQueryConverter.class); | ||
private final JsonPatchToSetActionConverter jsonPatchToSetActionConverter; | ||
private final JsonPatchToUnsetActionConverter jsonPatchToUnsetActionConverter; | ||
|
||
@Autowired | ||
public JsonPatchDtoToUpdateMultiQueryConverter(final JsonPatchToSetActionConverter jsonPatchToSetActionConverter, | ||
JsonPatchToUnsetActionConverter jsonPatchToUnsetActionConverter) { | ||
this.jsonPatchToSetActionConverter = jsonPatchToSetActionConverter; | ||
this.jsonPatchToUnsetActionConverter = jsonPatchToUnsetActionConverter; | ||
} | ||
|
||
@Override | ||
public UpdateMultiQuery convert(JsonPatchDto source) { | ||
try { | ||
final UpdateMultiQuery updateMultiQuery = new UpdateMultiQuery(); | ||
final Query query = QueryHelper.eq(GUID, source.getId()); | ||
updateMultiQuery.addQueries(query); | ||
|
||
final Action unset = jsonPatchToUnsetActionConverter.convert(source.getJsonPatch()); | ||
if (nonNull(unset)) { | ||
updateMultiQuery.addActions(unset); | ||
} | ||
|
||
final Action set = jsonPatchToSetActionConverter.convert(source.getJsonPatch()); | ||
if (nonNull(set)) { | ||
updateMultiQuery.addActions(set); | ||
} | ||
return updateMultiQuery; | ||
} catch (InvalidCreateOperationException e) { | ||
log.error("{}", e); | ||
throw new DslQueryCreateException(e); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...a/fr/gouv/vitamui/archives/search/common/dto/converter/JsonPatchToSetActionConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) | ||
* | ||
* contact.vitam@culture.gouv.fr | ||
* | ||
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing | ||
* high volumetry securely and efficiently. | ||
* | ||
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free | ||
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as | ||
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". | ||
* | ||
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, | ||
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the | ||
* successive licensors have only limited liability. | ||
* | ||
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or | ||
* developing or reproducing the software by the user in light of its specific status of free software, that may mean | ||
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and | ||
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the | ||
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data | ||
* to be ensured and, more generally, to use and operate it in the same conditions as regards security. | ||
* | ||
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you | ||
* accept its terms. | ||
*/ | ||
|
||
package fr.gouv.vitamui.archives.search.common.dto.converter; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import fr.gouv.vitam.common.database.builder.query.action.SetAction; | ||
import fr.gouv.vitam.common.database.builder.query.action.UpdateActionHelper; | ||
import fr.gouv.vitam.common.database.builder.request.exception.InvalidCreateOperationException; | ||
import fr.gouv.vitamui.archives.search.common.exception.DslQueryCreateException; | ||
import fr.gouv.vitamui.archives.search.common.model.JsonPatch; | ||
import fr.gouv.vitamui.archives.search.common.model.PatchCommand; | ||
import fr.gouv.vitamui.commons.api.logger.VitamUILogger; | ||
import fr.gouv.vitamui.commons.api.logger.VitamUILoggerFactory; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import static fr.gouv.vitamui.archives.search.common.model.PatchOperation.ADD; | ||
import static fr.gouv.vitamui.archives.search.common.model.PatchOperation.REPLACE; | ||
|
||
@Service | ||
public class JsonPatchToSetActionConverter implements Converter<JsonPatch, SetAction> { | ||
|
||
private static final VitamUILogger log = | ||
VitamUILoggerFactory.getInstance(JsonPatchToSetActionConverter.class); | ||
|
||
@Override | ||
public SetAction convert(JsonPatch source) { | ||
final Map<String, JsonNode> map = source.stream() | ||
.filter(patchCommand -> List.of(ADD, REPLACE).contains(patchCommand.getOp())) | ||
.collect(Collectors.toMap(PatchCommand::getPath, PatchCommand::getValue)); | ||
if (!map.isEmpty()) { | ||
try { | ||
return UpdateActionHelper.set(map); | ||
} catch (InvalidCreateOperationException e) { | ||
log.error("{}", e); | ||
throw new DslQueryCreateException(e); | ||
} | ||
} | ||
throw new DslQueryCreateException("Cannot create a query without commands"); | ||
} | ||
} |
Oops, something went wrong.