Skip to content

Commit

Permalink
6086 - fixing Elimination case for unpurging units.
Browse files Browse the repository at this point in the history
  • Loading branch information
thermoweb authored and Jean-Paul Pham committed Nov 14, 2019
1 parent adb3378 commit 1f2d917
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .gitlab/issue_templates/Bug.md
@@ -0,0 +1,6 @@
## Source
[TULEAP - XXXX](<link to issue>)

## Description

## Solution(s)
Expand Up @@ -2970,6 +2970,9 @@ STP_TRANSFER_REPLY_DELETE_UNIT.KO=Échec du processus de purge des unités archi
STP_TRANSFER_REPLY_DELETE_UNIT.FATAL=Erreur technique lors du processus de purge des unités archivistiques
STP_TRANSFER_REPLY_DELETE_UNIT.WARNING=Avertissement lors du processus de purge des unités archivistiques

LFC.UNIT_DELETION_ABORT=Échec du processus de purge de l''unité archivistique
LFC.UNIT_DELETION_ABORT.OK=Échec du processus de purge de l''unité archivistique

TRANSFER_REPLY_DELETE_UNIT=Purge des unités archivistiques
TRANSFER_REPLY_DELETE_UNIT.STARTED=Début de la purge des unités archivistiques
TRANSFER_REPLY_DELETE_UNIT.STARTED.OK=Succès du début de la purge des unités archivistiques
Expand Down
Expand Up @@ -724,7 +724,7 @@ private void checkTransferResult(String ingestOperationGuid, RequestResponseOK<J
logbookLifeCyclesClient.getRawUnitLifeCycleByIds(new ArrayList<>(expectedNonDeletableUnitIds));
for (JsonNode unitLifeCycle : unitLifeCycles) {
assertThat(unitLifeCycle.get("events").get(unitLifeCycle.get("events").size() - 1)
.get("outDetail").asText()).isEqualTo("LFC.UNIT_TRANSFERT_ABORT.OK");
.get("outDetail").asText()).isEqualTo("LFC.UNIT_DELETION_ABORT.OK");
}

// Check SIP transfer is deleted after atr reception
Expand Down
Expand Up @@ -78,6 +78,7 @@

import static fr.gouv.vitam.common.model.StatusCode.OK;
import static fr.gouv.vitam.common.model.StatusCode.WARNING;
import static fr.gouv.vitam.worker.core.plugin.transfer.reply.TransferReplyDeleteUnitPlugin.TRANSFER_REPLY_DELETE_UNIT;
import static fr.gouv.vitam.worker.core.utils.PluginHelper.buildItemStatus;
import static java.util.Collections.singletonList;

Expand All @@ -89,7 +90,7 @@ public class PurgeUnitPlugin extends ActionHandler {

private static final VitamLogger LOGGER = VitamLoggerFactory.getInstance(PurgeUnitPlugin.class);

private static final String UNIT_TRANSFER_ABORT = "UNIT_TRANSFERT_ABORT";
private static final String UNIT_DELETION_ABORT = "UNIT_DELETION_ABORT";

private final String actionId;
private final PurgeDeleteService purgeDeleteService;
Expand Down Expand Up @@ -136,10 +137,7 @@ public ItemStatus execute(WorkerParameters param, HandlerIO handler)
public List<ItemStatus> executeList(WorkerParameters param, HandlerIO handler) {

try {
List<ItemStatus> itemStatuses = processUnits(param.getContainerName(), param);

return itemStatuses;

return processUnits(param.getContainerName(), param);
} catch (ProcessingStatusException e) {
LOGGER.error("Unit purge failed with status " + e.getStatusCode(), e);
return singletonList(
Expand Down Expand Up @@ -180,16 +178,17 @@ private List<ItemStatus> processUnits(String processId, WorkerParameters param)
purgeUnitStatus = PurgeUnitStatus.DELETED;
itemStatuses.add(buildItemStatus(actionId, StatusCode.OK, null));
} else {
LOGGER.info("Unit " + unitId + " cannot be deleted because it has child units attached to it.");
String msg = "Unit " + unitId + " cannot be deleted because it has child units attached to it.";
LOGGER.info(msg);
purgeUnitStatus = PurgeUnitStatus.NON_DESTROYABLE_HAS_CHILD_UNITS;
try {
writeLfcForUnpurgedUnit(lfcClientFactory.getClient(), param, unitId);
itemStatuses.add(buildItemStatus(actionId, WARNING, null));
} catch (InvalidGuidOperationException | LogbookClientServerException | LogbookClientBadRequestException | LogbookClientNotFoundException e) {
LOGGER.error(e);
itemStatuses.add(buildItemStatus(UNIT_TRANSFER_ABORT, WARNING,
PluginHelper.EventDetails.of(String.format("Error '%s' while updating UNIT LFC.", e.getMessage()))
));
itemStatuses.add(buildItemStatus(actionId, WARNING, PluginHelper.EventDetails.of(msg)));
if(TRANSFER_REPLY_DELETE_UNIT.equals(actionId)) {
try {
writeLfcForUnpurgedUnit(lfcClientFactory.getClient(), param, unitId);
} catch (InvalidGuidOperationException | LogbookClientServerException |
LogbookClientBadRequestException | LogbookClientNotFoundException e) {
LOGGER.error(e);
}
}
}

Expand Down Expand Up @@ -282,12 +281,12 @@ private void writeLfcForUnpurgedUnit(LogbookLifeCyclesClient lfcClient, WorkerPa
LogbookLifeCycleParameters logbookLfcParam =
LogbookParametersFactory.newLogbookLifeCycleUnitParameters(
GUIDFactory.newEventGUID(ParameterHelper.getTenantParameter()),
VitamLogbookMessages.getEventTypeLfc(UNIT_TRANSFER_ABORT),
VitamLogbookMessages.getEventTypeLfc(UNIT_DELETION_ABORT),
GUIDReader.getGUID(param.getContainerName()),
param.getLogbookTypeProcess(),
OK,
VitamLogbookMessages.getOutcomeDetailLfc(UNIT_TRANSFER_ABORT, OK),
VitamLogbookMessages.getCodeLfc(UNIT_TRANSFER_ABORT, OK),
VitamLogbookMessages.getOutcomeDetailLfc(UNIT_DELETION_ABORT, OK),
VitamLogbookMessages.getCodeLfc(UNIT_DELETION_ABORT, OK),
GUIDReader.getGUID(unitId));
lfcClient.update(logbookLfcParam, LifeCycleStatusCode.LIFE_CYCLE_COMMITTED);
}
Expand Down
Expand Up @@ -35,7 +35,7 @@

public class TransferReplyDeleteUnitPlugin extends PurgeUnitPlugin {

private static final String TRANSFER_REPLY_DELETE_UNIT = "TRANSFER_REPLY_DELETE_UNIT";
public static final String TRANSFER_REPLY_DELETE_UNIT = "TRANSFER_REPLY_DELETE_UNIT";

/**
* Default constructor
Expand Down

0 comments on commit 1f2d917

Please sign in to comment.